MakoIoT.Device.Utilities.TimeZones 1.0.19.41562

There is a newer version of this package available.
See the version list below for details.
dotnet add package MakoIoT.Device.Utilities.TimeZones --version 1.0.19.41562
NuGet\Install-Package MakoIoT.Device.Utilities.TimeZones -Version 1.0.19.41562
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MakoIoT.Device.Utilities.TimeZones" Version="1.0.19.41562" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MakoIoT.Device.Utilities.TimeZones --version 1.0.19.41562
#r "nuget: MakoIoT.Device.Utilities.TimeZones, 1.0.19.41562"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MakoIoT.Device.Utilities.TimeZones as a Cake Addin
#addin nuget:?package=MakoIoT.Device.Utilities.TimeZones&version=1.0.19.41562

// Install MakoIoT.Device.Utilities.TimeZones as a Cake Tool
#tool nuget:?package=MakoIoT.Device.Utilities.TimeZones&version=1.0.19.41562

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:

  1. 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));
  1. 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 Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.21.23332 75 5/18/2024
1.0.20.26245 81 5/17/2024
1.0.19.41562 94 4/9/2024
1.0.18.43931 79 4/8/2024
1.0.17.54206 73 4/3/2024
1.0.16.52448 79 3/21/2024
1.0.15.64645 132 1/16/2024
1.0.13.59166 88 1/11/2024
1.0.12.46577 114 1/11/2024
1.0.11.47189 160 11/10/2023
1.0.9.41101 162 5/25/2023
1.0.8.16939 139 5/25/2023