MakoIoT.Device.Utilities.TimeZones
1.0.21.23332
See the version list below for details.
dotnet add package MakoIoT.Device.Utilities.TimeZones --version 1.0.21.23332
NuGet\Install-Package MakoIoT.Device.Utilities.TimeZones -Version 1.0.21.23332
<PackageReference Include="MakoIoT.Device.Utilities.TimeZones" Version="1.0.21.23332" />
paket add MakoIoT.Device.Utilities.TimeZones --version 1.0.21.23332
#r "nuget: MakoIoT.Device.Utilities.TimeZones, 1.0.21.23332"
// Install MakoIoT.Device.Utilities.TimeZones as a Cake Addin #addin nuget:?package=MakoIoT.Device.Utilities.TimeZones&version=1.0.21.23332 // Install MakoIoT.Device.Utilities.TimeZones as a Cake Tool #tool nuget:?package=MakoIoT.Device.Utilities.TimeZones&version=1.0.21.23332
Mako-IoT.Device.Utilities.TimeZones
The way to get local date & time on your device. Given time zone definition the library converts UTC to local time, handles Daylight Saving Time transitions as well.
Usage
Create TimeZone object
Time zone without DST
var timezone = new TimeZone(utcOffset);
Time zone with DST
var timezone = new TimeZone(standardUtcOffset, dstUtcOffset, dstStarts, dstEnds);
DST transition dates
Time zones across the globe have various rules about transition to and from DST. To accomodate that we can provide transition dates in two ways:
- FixedDate - fixed month and day of the year
//DST starts every year on the 20th of June at 2:00 AM
var dstStarts = new FixedDate(new DateTime(2023, 20, 6, 2, 0, 0));
- FloatingDate - weekday of given week in a month
//DST starts on the second Sunday of March at 2:00 AM
var dstStarts = new FloatingDate(3, 2, DayOfWeek.Sunday, 2, 0, 0);
Get date & time
Getting local time
var localTime = timezone.GetLocalTime(utcDateTime);
Check if DST is observed at given date and time
var isDst = timezone.IsDst(utcDateTime);
POSIX format
POSIX format lets you define all time zone's details in a compact string. For example "CET-1CEST,M3.5.0,M10.5.0/3" means:
- Standard time name: CET
- UTC offset: -1 hour
- DST time name: CEST
- DST starts on the last (5) Sunday (0) of March (3) at 2:00 AM (/3)
- DST ends on the last (5) Sunday (0) of October (10) at 3:00 AM (/3)
Use TimeZoneConverter to parse POSIX string into TimeZone object and vice versa
var timezone = TimeZoneConverter.FromPosixString(posixString);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Collections (>= 1.5.31)
- nanoFramework.System.IO.Streams (>= 1.1.15)
- nanoFramework.System.Text (>= 1.2.54)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.34.62093 | 61 | 10/31/2024 |
1.0.33.4058 | 110 | 10/18/2024 |
1.0.32.53729 | 64 | 10/16/2024 |
1.0.31.59815 | 78 | 9/30/2024 |
1.0.30.19105 | 78 | 9/26/2024 |
1.0.29.38441 | 86 | 9/20/2024 |
1.0.28.62450 | 99 | 9/12/2024 |
1.0.27.45223 | 110 | 9/5/2024 |
1.0.24.14493 | 97 | 8/29/2024 |
1.0.23.19968 | 105 | 8/10/2024 |
1.0.22.1635 | 91 | 6/12/2024 |
1.0.21.23332 | 110 | 5/18/2024 |
1.0.20.26245 | 114 | 5/17/2024 |
1.0.19.41562 | 118 | 4/9/2024 |
1.0.18.43931 | 106 | 4/8/2024 |
1.0.17.54206 | 97 | 4/3/2024 |
1.0.16.52448 | 105 | 3/21/2024 |
1.0.15.64645 | 157 | 1/16/2024 |
1.0.13.59166 | 113 | 1/11/2024 |
1.0.12.46577 | 136 | 1/11/2024 |
1.0.11.47189 | 185 | 11/10/2023 |
1.0.9.41101 | 184 | 5/25/2023 |
1.0.8.16939 | 165 | 5/25/2023 |