Releases: skybrud/Skybrud.Essentials
Skybrud.Essentials v1.1.15
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
Installation
Changelog
-
Added null check to
JObjectExtensions.GetArrayextension 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 theStringUtilsclass 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
Installation
Changelog
-
Marked legacy code in
StringHelperandStringHelpersclasses as obsolete (see bc9af3b)
Both were replaced by theStringUtilsclass a while ago, but the obsolete attributes were either missing or referencing the wrong class. -
Updated the the
Parsemethod in theEssentialsDateclass to return the correct type (see 0c1df51 )
The method would return an instance ofEssentialsTime, which was wrong. It now correctly turns an instance ofEssentialsDate. -
Added
ParseExact,TryParseandTryParseExactmethods to theEssentialsDateclass (see cc11946) -
Updated the
TimeConverterJSON converter to support serializing and deserializingEssentialsDate(see a0d4332) -
Updated the
EssentialsDateclass to implementIComparable(see aad3cff)
The commit also overrides theEquals,GetHashCodemethods as well as implements a number of comparison overloads.
Skybrud.Essentials v1.1.12
Installation
Skybrud.Essentials v1.1.11
Installation
Changelog
-
Replaced the
Locationsnamespace with a newMapsnamespace (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
IPointinterfaces replaces the oldILocationinterface. In a similar way, thePointclass replaces theEssentialsLocationclass. The old types still exist in the package, but are not marked as obsolete. -
Added
ParseBooleanoverloads to theStringUtilsclass (see 45b89f4)
The existingParseBooleanmethods doesn't take a fallback parameter, and as such will always returnfalseif the input value doesn't match a known value for a booleantrue.The two new overloads take a
fallbackparameter which is returned if the input value doesn't explicitly match a known value for either a booleantrueorfalse. 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
ToBooleanextension methods forstring(see 9a00350)
Similar to theParseBooleanutility methods, aToBooleanextension method can now be called directly on astring."".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
Installation
Changelog
-
EnumUtils.TryParsewill 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 returnfalseinstead of throwing an exception. -
Added new constructor overloads to the
EssentialsTimeclass (see de2896c)
TheEssentialsTimeclass can now also be initialized from an instance ofEssentialsDatewith three new constructor overloads:- EssentialsTime(EssentialsDate date)
- EssentialsTime(EssentialsDate date, TimeSpan offset)
- EssentialsTime(EssentialsDate date, TimeZoneInfo timeZone)
-
Added input validation for
EssentialsTimeconstructors (see fccf16c)
The constructors in theEssentialsTimeclass will now throw an exception of typeArgumentNullExceptionwhen a required parameter is passed asnull. -
Operator overloading (see 6e686d2).
Added operator overload to theEssentialsTimeallowing it to be converted from an instance ofDateTime.
Skybrud.Essentials v1.1.9
Installation
Changelog
-
Added time zone support to the
EssentialsTimeclass
With the help ofTimeZoneInfoandDateTimeOffset, instances ofEssentialsTimecan 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
EssentialsDateclass
While theEssentialsTimeclass representing a specific date and time, theEssentialsDateclass 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
EssentialsWeekclass
The newEssentialsWeekclass represents an entire ISO 8601 week. It may be based on a specificTimeZoneInfo, 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 is2019-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
Installation
Changelog
-
Introduced new
EnumStringConverterJSON converter class to replace existing converters. The classesEnumPascalCaseConverter,EnumLowerCaseConverterandEnumCamelCaseConverterhave 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.LowerCaseTextCasing.UpperCaseTextCasing.CamelCaseTextCasing.PascalCaseTextCasing.KebabCaseTextCasing.TrainCaseTextCasing.Underscore
-
Introduced new
TimeConverterJSON converter class. Besides providing new functionality, the new converter also replacesEssentialsDateTimeConverterandUnixTimeConverter.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.Iso8601TimeFormat.Rfc822TimeFormat.Rfc2822TimeFormat.UnixTime
TimeConverteris now the default JSON converter forEssentialsDateTimeandEssentialsTime.
Skybrud.Essentials v1.1.7
Installation
Changelog
- Introduced new class
EssentialsTimeserving as a wrapper class forDateTimeOffsetand with extended functionality.
Skybrud.Essentials v1.1.6
Installation
Changelog
- Fixed a bug in the
ToUnderscoreextension methods as they incorrectly converted to train case instead of underscore (see 82fba36).