Releases: skybrud/Skybrud.Essentials
Skybrud.Essentials v1.1.17
Installation
Changelog
-
Added
YearAndDate
properties to theEssentialsTime
andEssentialsDate
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 inEssentialsTime
(see 04b23e7 and #10)
The property compared against a wrong value, causing it to never betrue
- even when should be.. -
Added new
DaySuffix
properties to theEssentialsTime
andEssentialsDate
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 theEssentialsDate
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, ordate.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 eachEssentialsDate
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 theToString
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)
TheEssentialsWeek
now has two ned constructor overloads, where the first takes an instance ofEssentialsDate
and the second takes both anEssentialsDate
and aTimeZoneInfo
. -
Various improvements to the
EssentialsWeek
class (see 7833df1)
Improvements include a constructor overload taking ayear
,month
andday
. -
Introduced the
EssentialsWeekRange
class (see 1754af4)
By giving the constructor a start and end week, the class let's you iterate over eachEssentialsWeek
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
Installation
Changelog
-
Individual enum string converter classes are no longer marked as obsolete (see 39899ec)
TheEnumCamelCaseConveter
,EnumLowerCaseConverter
andEnumPascalCaseConverter
classes now inherit from theEnumStringConverter
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 fromTimeConverter
and specifies that the format should be unix time. -
Added more
GetAge
method overloads to theTimeUtils
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 ofEssentialsDate
. -
Added extra properties to the
EssentialsTime
class (see f2c15bc)
Added properties includeIsToday
,DayName
andMonthName
. -
Added
JsonConverter
attribute to theEssentialsDate
class (see 133a333)
TheJsonConverter
attribute now specifies that theTimeConverter
class should be used when serializing and deserializing instances ofEssentialsDate
. This means that instances will be serialized to an ISO 8601 formatted string instead of a JSON object will all the properties of theEssentialsDate
class.
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.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 theStringUtils
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
Installation
Changelog
-
Marked legacy code in
StringHelper
andStringHelpers
classes as obsolete (see bc9af3b)
Both were replaced by theStringUtils
class a while ago, but the obsolete attributes were either missing or referencing the wrong class. -
Updated the the
Parse
method in theEssentialsDate
class 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
,TryParse
andTryParseExact
methods to theEssentialsDate
class (see cc11946) -
Updated the
TimeConverter
JSON converter to support serializing and deserializingEssentialsDate
(see a0d4332) -
Updated the
EssentialsDate
class to implementIComparable
(see aad3cff)
The commit also overrides theEquals
,GetHashCode
methods as well as implements a number of comparison overloads.
Skybrud.Essentials v1.1.12
Installation
Skybrud.Essentials v1.1.11
Installation
Changelog
-
Replaced the
Locations
namespace with a newMaps
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 oldILocation
interface. In a similar way, thePoint
class replaces theEssentialsLocation
class. The old types still exist in the package, but are not marked as obsolete. -
Added
ParseBoolean
overloads to theStringUtils
class (see 45b89f4)
The existingParseBoolean
methods doesn't take a fallback parameter, and as such will always returnfalse
if the input value doesn't match a known value for a booleantrue
.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 booleantrue
orfalse
. 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 forstring
(see 9a00350)
Similar to theParseBoolean
utility methods, aToBoolean
extension 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.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 returnfalse
instead of throwing an exception. -
Added new constructor overloads to the
EssentialsTime
class (see de2896c)
TheEssentialsTime
class can now also be initialized from an instance ofEssentialsDate
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 theEssentialsTime
class will now throw an exception of typeArgumentNullException
when a required parameter is passed asnull
. -
Operator overloading (see 6e686d2).
Added operator overload to theEssentialsTime
allowing it to be converted from an instance ofDateTime
.
Skybrud.Essentials v1.1.9
Installation
Changelog
-
Added time zone support to the
EssentialsTime
class
With the help ofTimeZoneInfo
andDateTimeOffset
, instances ofEssentialsTime
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 theEssentialsTime
class representing a specific date and time, theEssentialsDate
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 newEssentialsWeek
class 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
EnumStringConverter
JSON converter class to replace existing converters. The classesEnumPascalCaseConverter
,EnumLowerCaseConverter
andEnumCamelCaseConverter
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 replacesEssentialsDateTimeConverter
andUnixTimeConverter
.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 forEssentialsDateTime
andEssentialsTime
.