Skip to content

Releases: skybrud/Skybrud.Essentials

Skybrud.Essentials v1.1.15

08 Aug 15:22

Choose a tag to compare

Installation

Changelog

  • All logic for parsing various types of numbers should be culture invariant (see bb4b0b4).
    Follow up from last release as not all methods where updated to be culture invariant. The code now also contains unit tests to confirm that this has now actually been fixed.

Skybrud.Essentials v1.1.14

05 Aug 11:47

Choose a tag to compare

Installation

Changelog

  • Added null check to JObjectExtensions.GetArray extension method - thanks to @bielu for the PR (see ab8c52e)
    While an array item that is null is typically a sign of a problem with the underlying JSON data, the method will now skip items that are null.

  • All logic for parsing various types of numbers should be culture invariant (see db820e4)
    The various number parsing methods in the StringUtils class did not specify a culture, and the parsing would therefore fall back to the culture of the current thread. With this release, those methods now specify that an invariant culture should be used for the parsing (as it should have been all along).

Skybrud.Essentials v1.1.13

24 Jul 12:11

Choose a tag to compare

Installation

Changelog

  • Marked legacy code in StringHelper and StringHelpers classes as obsolete (see bc9af3b)
    Both were replaced by the StringUtils class a while ago, but the obsolete attributes were either missing or referencing the wrong class.

  • Updated the the Parse method in the EssentialsDate class to return the correct type (see 0c1df51 )
    The method would return an instance of EssentialsTime, which was wrong. It now correctly turns an instance of EssentialsDate.

  • Added ParseExact, TryParse and TryParseExact methods to the EssentialsDate class (see cc11946)

  • Updated the TimeConverter JSON converter to support serializing and deserializing EssentialsDate (see a0d4332)

  • Updated the EssentialsDate class to implement IComparable (see aad3cff)
    The commit also overrides the Equals, GetHashCode methods as well as implements a number of comparison overloads.

Skybrud.Essentials v1.1.12

28 Apr 20:50

Choose a tag to compare

Skybrud.Essentials v1.1.11

27 Apr 15:15

Choose a tag to compare

Installation

Changelog

  • Replaced the Locations namespace with a new Maps namespace (see ca2e026)
    The classes and their names are changed a bit to be better suited for an upcoming Skybrud.Essentials.Maps package.

    Specifically this means that the IPoint interfaces replaces the old ILocation interface. In a similar way, the Point class replaces the EssentialsLocation class. The old types still exist in the package, but are not marked as obsolete.

  • Added ParseBoolean overloads to the StringUtils class (see 45b89f4)
    The existing ParseBoolean methods doesn't take a fallback parameter, and as such will always return false if the input value doesn't match a known value for a boolean true.

    The two new overloads take a fallback parameter which is returned if the input value doesn't explicitly match a known value for either a boolean true or false. This means that you can now do something like:

    StringUtils.ParseBoolean("", true); // falls back to "true"
    StringUtils.ParseBoolean("0", true); // returns "false" because "0" is a known value
  • Added ToBoolean extension methods for string (see 9a00350)
    Similar to the ParseBoolean utility methods, a ToBoolean extension method can now be called directly on a string.

    "".ToBoolean(); // falls back to "false"
    "".ToBoolean(true); // falls back to "true"
    "0".ToBoolean(true); // returns "false" because "0" is a known value

Skybrud.Essentials v1.1.10

07 Apr 13:26

Choose a tag to compare

Installation

Changelog

  • EnumUtils.TryParse will no longer throw an exception if input is null or white space (see c03305e and #7)
    The idea is that the method should fail silently, so it should just return false instead of throwing an exception.

  • Added new constructor overloads to the EssentialsTime class (see de2896c)
    The EssentialsTime class can now also be initialized from an instance of EssentialsDate with three new constructor overloads:

    • EssentialsTime(EssentialsDate date)
    • EssentialsTime(EssentialsDate date, TimeSpan offset)
    • EssentialsTime(EssentialsDate date, TimeZoneInfo timeZone)
  • Added input validation for EssentialsTime constructors (see fccf16c)
    The constructors in the EssentialsTime class will now throw an exception of type ArgumentNullException when a required parameter is passed as null .

  • Operator overloading (see 6e686d2).
    Added operator overload to the EssentialsTime allowing it to be converted from an instance of DateTime.

Skybrud.Essentials v1.1.9

24 Mar 14:16

Choose a tag to compare

Installation

Changelog

  • Added time zone support to the EssentialsTime class
    With the help of TimeZoneInfo and DateTimeOffset, instances of EssentialsTime can now be based on a specific time zone in addition to a given offset. This helps date and time operations to work even between different time zones and also taking daylight savings into account. A lot of the underlying logic has also been updated to support this change.

  • Introduced the EssentialsDate class
    While the EssentialsTime class representing a specific date and time, the EssentialsDate class only represents the date, which may be beneficial in some date and time operations.

    As it only represents the date, and not the time, it's not based on any offset or time zone. It is however possible to specify a time zone for some of the methods of the class. According to Romance Standard Time, the 31st of March 2019 starts with an offset of a single hour to UTC (2019-03-31T00:00:00+01:00), but ends with an offset of two hours (2019-03-31T23:59:59+02:00) due to daylight savings:

    TimeZoneInfo cet = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
    
    EssentialsDate march31 = new EssentialsDate(2019, 3, 31);
    
    <pre>@march31.GetStartOfDay(cet).Iso8601</pre>
    <pre>@march31.GetEndOfDay(cet).Iso8601</pre>
  • Introduced the EssentialsWeek class
    The new EssentialsWeek class represents an entire ISO 8601 week. It may be based on a specific TimeZoneInfo, in which case daylight savings is also taken into account for determining the start and end times of the week.

    This can be illustrated by the example below. Romance Standard Time switches to Romance Summer Time on the last Sunday of March, which in 2019 is week 13. This means that the start of week 13 is 2019-03-25T00:00:00+01:00, but the start of week 14 is 2019-04-01T00:00:00+02:00.

    TimeZoneInfo romance = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
      
    EssentialsWeek week1 = new EssentialsWeek(2019, 13, romance);
    EssentialsWeek week2 = new EssentialsWeek(2019, 14, romance);
      
    <pre>@week1.Start.Iso8601</pre>
    <pre>@week2.Start.Iso8601</pre>

Skybrud.Essentials v1.1.8

20 Jan 14:20

Choose a tag to compare

Installation

Changelog

  • Introduced new EnumStringConverter JSON converter class to replace existing converters. The classes EnumPascalCaseConverter, EnumLowerCaseConverter and EnumCamelCaseConverter have now been marked as obsolete.

    The new converter works by specifying the format to be used when serializing to JSON - eg. by decorating the property with an attribute like:

    [JsonConverter(typeof(EnumStringConverter), TextCasing.KebabCase)]
    public HttpStatusCode StatusCode { get; set; }

    Supported formats are (default is TextCasing.PascalCase):

    • TextCasing.LowerCase
    • TextCasing.UpperCase
    • TextCasing.CamelCase
    • TextCasing.PascalCase
    • TextCasing.KebabCase
    • TextCasing.TrainCase
    • TextCasing.Underscore
  • Introduced new TimeConverter JSON converter class. Besides providing new functionality, the new converter also replaces EssentialsDateTimeConverter and UnixTimeConverter.

    The new converter can be used by adding the following attribute on the property:

    [JsonConverter(typeof(TimeConverter), TimeFormat.Iso8601)]
    public DateTime Time { get; set; }

    Supported formats are (default is TimeFormat.Iso8601):

    • TimeFormat.Iso8601
    • TimeFormat.Rfc822
    • TimeFormat.Rfc2822
    • TimeFormat.UnixTime

    TimeConverter is now the default JSON converter for EssentialsDateTime and EssentialsTime.

Skybrud.Essentials v1.1.7

13 Jan 12:48

Choose a tag to compare

Installation

Changelog

  • Introduced new class EssentialsTime serving as a wrapper class for DateTimeOffset and with extended functionality.

Skybrud.Essentials v1.1.6

29 Sep 15:24

Choose a tag to compare

Installation

Changelog

  • Fixed a bug in the ToUnderscore extension methods as they incorrectly converted to train case instead of underscore (see 82fba36).