Date | 2019-03-24 (2,069 days ago) |
---|---|
Downloads | 994 downloads |
NuGet | View on NuGet |
GitHub | View on GitHub |
Target Frameworks | .NET Standard 1.1 .NET Standard 1.3 .NET 4.5 .NET 4.6 .NET 4.7 |
#installation
">Installation#changelog
">ChangelogAdded 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>