Sion.Useful 2.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sion.Useful --version 2.3.0
NuGet\Install-Package Sion.Useful -Version 2.3.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="2.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sion.Useful --version 2.3.0
#r "nuget: Sion.Useful, 2.3.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=2.3.0

// Install Sion.Useful as a Cake Tool
#tool nuget:?package=Sion.Useful&version=2.3.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 CamelCaseToPascalCase(string camelCase)
public static string CamelCaseToSnakeCase(string camelCase)
public static string PascalCaseToCamelCase(string pascalCase)
public static string PascalCaseToSnakeCase(string pascalCase)
public static string SnakeCaseToCamelCase(string snakeCase)
public static string SnakeCaseToPascalCase(string snakeCase)
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
Converting between snake_case, camelCase, and PascalCase
// These are only available as static methods
string camelCase = "testTest";
string pascalCase = StringMethods.CamelCaseToPascalCase(camelCase); // TestTest
string snakeCase = StringMethods.CamelCaseToSnakeCase(camelCase); // test_test

pascalCase = "SecondTest";
camelCase = StringMethods.PascalCaseToCamelCase(pascalCase); // secondTest
snakeCase = StringMethods.PascalCaseToSnakeCase(pascalCase); // second_test

snakeCase = "last_test";
camelCase = StringMethods.SnakeCaseToCamelCase(snakeCase); // lastTest
pascalCase = StringMethods.SnakeCaseToPascalCase(snakeCase); // LastTest
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.
  • net6.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 92 2/2/2024
2.3.0 176 6/26/2023
2.2.2 121 6/13/2023
2.2.1 224 2/26/2023
2.2.0 366 10/24/2022
2.1.0 374 10/10/2022
2.0.1 368 9/6/2022
2.0.0 424 1/17/2022
1.1.2 307 9/6/2021
1.1.1 282 9/6/2021
1.1.0 301 9/6/2021
1.0.0 297 9/6/2021

Some extension methods.