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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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.
Update to .NET 8. Removed some functionality that is provided in other Useful packages.