Sion.Useful 3.0.0

dotnet add package Sion.Useful --version 3.0.0                
NuGet\Install-Package Sion.Useful -Version 3.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sion.Useful" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sion.Useful --version 3.0.0                
#r "nuget: Sion.Useful, 3.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sion.Useful as a Cake Addin
#addin nuget:?package=Sion.Useful&version=3.0.0

// Install Sion.Useful as a Cake Tool
#tool nuget:?package=Sion.Useful&version=3.0.0                

Sion.Useful

NuGet package that provides static and extension methods to DateTime and string.

Sion.Useful.DateTimeMethods

public static long ConvertToUnixMilliseconds(DateTime date)
public static long ConvertToUnixSeconds(DateTime date)
public static long GetUnixMillisecondsNow()
public static long GetUnixSecondsNow()
public static long ToUnixMilliseconds(this DateTime date)
public static long ToUnixSeconds(this DateTime date)

Sion.Useful.StringMethods

public static string Base64ToUtf8(this string base64)
public static string Utf8ToBase64(this string utf8)

How to use

First, download the Sion.Useful NuGet package, then include this using statement at the top of the file:

using Sion.Useful;

DateTimeMethods

Getting Unix seconds and milliseconds
// Using extension methods
DateTime date = Convert.ToDateTime("2000-01-01T12:00:00.000");
long unixMilliseconds = date.ToUnixMilliseconds();
long unixSeconds = date.ToUnixSeconds();

long unixMillisecondsNow = DateTime.Now.ToUnixMilliseconds();
long unixSeconds = DateTime.Now.ToUnixSeconds();
// Using static methods
DateTime date = Convert.ToDateTime("2000-01-01T12:00:00.000");
long unixMilliseconds = DateTimeMethods.ConvertToUnixMilliseconds(date);
long unixSeconds = DateTimeMethods.ConvertToUnixSeconds(date);

long unixMillisecondsNow = DateTimeMethods.GetUnixMillisecondsNow();
long unixSecondsNow = DateTimeMethods.GetUnixSecondsNow();

StringMethods

Converting between UTF-8 and Base64 strings
// Using extension methods
string utf8 = "hello";
string base64 = utf8.Utf8ToBase64(); // aGVsbG8=

base64 = "Ym9uam91cg==";
utf8 = base64.Base64ToUtf8(); // bonjour
// Using static methods
string utf8 = "hello";
string base64 = StringMethods.Utf8ToBase64(utf8); // aGVsbG8=

base64 = "Ym9uam91cg==";
utf8 = StringMethods.Base64ToUtf8(base64); // bonjour
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 96 2/2/2024
2.3.0 178 6/26/2023
2.2.2 122 6/13/2023
2.2.1 227 2/26/2023
2.2.0 369 10/24/2022
2.1.0 375 10/10/2022
2.0.1 370 9/6/2022
2.0.0 425 1/17/2022
1.1.2 309 9/6/2021
1.1.1 283 9/6/2021
1.1.0 302 9/6/2021
1.0.0 298 9/6/2021

Update to .NET 8. Removed some functionality that is provided in other Useful packages.