Skip to content

Releases: skybrud/Skybrud.Essentials

Skybrud.Essentials v1.1.17

20 Oct 18:29
Compare
Choose a tag to compare

Installation

Changelog

  • Added YearAndDate properties to the EssentialsTime and EssentialsDate classes (see 5cb10ee)
    The new properties expose the date as a numeric value based on both the year and the day of the year, which makes the value ideal for comparing and sorting.

  • Fixed issue with the IsToday property in EssentialsTime (see 04b23e7 and #10)
    The property compared against a wrong value, causing it to never be true - even when should be..

  • Added new DaySuffix properties to the EssentialsTime and EssentialsDate classes (see 097d56d)
    The properties return the English day suffix (eg. 1st, 2nd and so forth) based on the underlying date.

  • Added new AddDays method to the EssentialsDate class (see ffe7cd4)
    The new method allows you to add a number of days to a date - eg. date.AddDays(1) to get the next day, or date.AddDays(-1) to get the previous date.

  • Introduced new EssentialsDateRange class (see d6f05a7)
    By giving the constructor a start and end date, the class let's you iterate over each EssentialsDate within the range. The class let's you iterate both in regular and reverse order depending on the input to the constructor.

  • Introduced new ToStringJsonConverter JSON converter (see 80288e1 and #9)
    The JSON converter will automatically call the ToString method on the object it's supposed to serialize. The JSON converter does not support deserialization.

  • Added new constructor overloads to the EssentialsWeek class (see 60dc84e)
    The EssentialsWeek now has two ned constructor overloads, where the first takes an instance of EssentialsDate and the second takes both an EssentialsDate and a TimeZoneInfo.

  • Various improvements to the EssentialsWeek class (see 7833df1)
    Improvements include a constructor overload taking a year, month and day.

  • Introduced the EssentialsWeekRange class (see 1754af4)
    By giving the constructor a start and end week, the class let's you iterate over each EssentialsWeek within the range. The class let's you iterate both in regular and reverse order depending on the input to the constructor.

v1.1.16

15 Sep 18:03
Compare
Choose a tag to compare

Installation

Changelog

  • Individual enum string converter classes are no longer marked as obsolete (see 39899ec)
    The EnumCamelCaseConveter, EnumLowerCaseConverter and EnumPascalCaseConverter classes now inherit from the EnumStringConverter class in stead of having their own implementations.

  • UnixTimeConverter JSON converter is no longer obsolete (see cb4ab55)
    Instead of having it's own implementation (which was why the class was marked as obsolete), the class now inherits from TimeConverter and specifies that the format should be unix time.

  • Added more GetAge method overloads to the TimeUtils class (see 5db70b9 and a4bff3e)
    The added overloads support different types of parameters - eg. it's now possible to calculate the age between two instances of EssentialsDate.

  • Added extra properties to the EssentialsTime class (see f2c15bc)
    Added properties include IsToday, DayName and MonthName.

  • Added JsonConverter attribute to the EssentialsDate class (see 133a333)
    The JsonConverter attribute now specifies that the TimeConverter class should be used when serializing and deserializing instances of EssentialsDate. This means that instances will be serialized to an ISO 8601 formatted string instead of a JSON object will all the properties of the EssentialsDate class.

Skybrud.Essentials v1.1.15

08 Aug 15:22
Compare
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
Compare
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
Compare
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
Compare
Choose a tag to compare

Skybrud.Essentials v1.1.11

27 Apr 15:15
Compare
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
Compare
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
Compare
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
Compare
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.