Skip to content

Skybrud.Essentials v1.1.36

Compare
Choose a tag to compare
@abjerner abjerner released this 14 Feb 15:45
· 199 commits to v1/main since this release

Installation

Install the NuGet package - either via the .NET CLI:

dotnet add package Skybrud.Essentials --version 1.1.36

or the NuGet package manager:

Install-Package Skybrud.Essentials -Version 1.1.36

Changelog

  • Introduced new constants to the Iso8601Constants class (see b6c2961)
    As part of introducing better support for milliseconds, this release introduces the Date, DateTimeSeconds and DateTimeMilliseconds constants. The DateFormat (replaced by Date) and DateTimeFormat (replaced by DateTimeSeconds) are now marked as obsolete.

  • Introduced new logic for working with Unix time in milliseconds (see fe79cb5)
    New methods were added to the EssentialsTime and UnixTimeUtils classes for making working with Unix time more convenient. Changes include:

    • Marked EssentialsTime.FromUnixTimestamp methods as obsolete (as it was replaced by EssentialsTime.FromUnixTimeSeconds)
    • Introduced new EssentialsTime.FromUnixTimeSeconds methods
    • Introduced new EssentialsTime.FromUnixTimeMilliseconds methods
    • Introduced new UnixTimeUtils.FromMilliseconds methods
    • Introduced new UnixTimeUtils.ToMilliseconds methods
  • Introduced new UnixTimeFormat enum for UnixTimeConverter class (see a6837d6)
    The JSON converter now supports specifying the format of the converter - either UnixTimeFormat.Seconds (default) or UnixTimeFormat.Milliseconds. Until now, the converter has only supported converting back and forth between the UNIX timestamp expressed with seconds, but by setting the format to UnixTimeFormat.Milliseconds, the converter will now convert back and forth between milliseconds instead.

  • Improved the Unix time logic in the EssentialsTime class (see 32860ca)
    New properties were added to the EssentialsTime class for making working with Unix time more convenient. Changes include:

    • Introduced new CurrentUnixTimeSeconds static property
    • Introduced new CurrentUnixTimeMilliseconds static property
    • Marked UnixTimestamp property as obsolete (as it was replaced by UnixTimeSeconds)
    • Introduced new UnixTimeSeconds property
    • Introduced new UnixTimeMilliseconds property
    • Introduced new ToUnixTimeSeconds methodty
    • Introduced new ToUnixTimeMilliseconds method
  • EssentialsDate.TryParse method should invariant culture if not a culture isn't explicitly specified (see 1733f2f)
    The general idea with Skybrud.Essentials is that various logic should be culture invariant - unless specified otherwise. The TryParse(string input, out EssentialsDate result) relied on the current culture, which was wrong.

  • Added new method overloads to the ReflectionUtils class (see 3753413)
    As typical usage to get the version of an assembly would be something like ReflectionUtils.GetVersion(typeof(MyType).Assembly), it's now possibly to use ReflectionUtils.GetVersion<MyType>() instead.

  • Introduced new TryParseJsonToken, TryParseJsonObject and TryParseJsonArray method to the JsonUtils class (see dfef0f7)
    The new methods add a more safe way of parsing JSON values - eg. if the validity of the JSON is not certain. The implementation will catch an exception should it be triggered by JSON.net's parsing logic. It may still be best to do some simple validation on the input value first - eg. if it starts with [ or {.

  • Introduced new StringUtils.ParseHexString method (see 3fa44a3)
    The method allows parsing a HEX string into a corresponding byte array; the opposite of the StringUtils.ToHexString method.