Skybrud.Essentials v1.1.36
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 theDate
,DateTimeSeconds
andDateTimeMilliseconds
constants. TheDateFormat
(replaced byDate
) andDateTimeFormat
(replaced byDateTimeSeconds
) are now marked as obsolete. -
Introduced new logic for working with Unix time in milliseconds (see fe79cb5)
New methods were added to theEssentialsTime
andUnixTimeUtils
classes for making working with Unix time more convenient. Changes include:- Marked
EssentialsTime.FromUnixTimestamp
methods as obsolete (as it was replaced byEssentialsTime.FromUnixTimeSeconds
) - Introduced new
EssentialsTime.FromUnixTimeSeconds
methods - Introduced new
EssentialsTime.FromUnixTimeMilliseconds
methods - Introduced new
UnixTimeUtils.FromMilliseconds
methods - Introduced new
UnixTimeUtils.ToMilliseconds
methods
- Marked
-
Introduced new
UnixTimeFormat
enum forUnixTimeConverter
class (see a6837d6)
The JSON converter now supports specifying the format of the converter - eitherUnixTimeFormat.Seconds
(default) orUnixTimeFormat.Milliseconds
. Until now, the converter has only supported converting back and forth between the UNIX timestamp expressed with seconds, but by setting the format toUnixTimeFormat.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 theEssentialsTime
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 byUnixTimeSeconds
) - Introduced new
UnixTimeSeconds
property - Introduced new
UnixTimeMilliseconds
property - Introduced new
ToUnixTimeSeconds
methodty - Introduced new
ToUnixTimeMilliseconds
method
- Introduced new
-
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. TheTryParse(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 likeReflectionUtils.GetVersion(typeof(MyType).Assembly)
, it's now possibly to useReflectionUtils.GetVersion<MyType>()
instead. -
Introduced new
TryParseJsonToken
,TryParseJsonObject
andTryParseJsonArray
method to theJsonUtils
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 theStringUtils.ToHexString
method.