Afk.ZoneInfo 4.2.0

dotnet add package Afk.ZoneInfo --version 4.2.0                
NuGet\Install-Package Afk.ZoneInfo -Version 4.2.0                
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="Afk.ZoneInfo" Version="4.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Afk.ZoneInfo --version 4.2.0                
#r "nuget: Afk.ZoneInfo, 4.2.0"                
#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 Afk.ZoneInfo as a Cake Addin
#addin nuget:?package=Afk.ZoneInfo&version=4.2.0

// Install Afk.ZoneInfo as a Cake Tool
#tool nuget:?package=Afk.ZoneInfo&version=4.2.0                

TimeZone

Afk.ZoneInfo is an alternative to the framework class System.TimeZoneInfo.

The Afk.ZoneInfo use the Iana timezone database (previously named Olson Database). By default the library is linked with a database files. You can override it with recent files, for this set the environment variable TZDIR with the new directory of database files.

VERSION

The library is compatible with netstandard2.0

NUGET

The easiest way to install is by using NuGet.

HowTo

Local time zone can be retrieve by the static TzTimeZone.CurrentTzTimeZone member. The following code uses the CurrentTzTimeZone to return the local times that correspond to UTC.

TzTimeZone local = TzTimeZone.CurrentTzTimeZone;
Console.WriteLine(local.ToLocalTime(DateTime.UtcNow));

Specific time zone can be retrieve by the static TzTimeInfo.GetZone function and translation are provide by ToLocalTime and ToUniversalTime functions.

DateTime dateLocal = new DateTime(2011, 1, 5, 10, 0, 0, DateTimeKind.Local);
TzTimeZone paris = TzTimeInfo.GetZone("Europe/Paris");
TzTimeZone ny = TzTimeInfo.GetZone("America/New_York");
DateTime dateUtc = paris.ToUniversalTime(dateLocal);
Console.WriteLine("Local time at paris : " + dateLocal + " UTC : " + dateUtc);
Console.WriteLine("Local time at new york : " + ny.ToLocalTime(dateUtc));
Console.WriteLine("");
Console.WriteLine("Paris : " + dateLocal + " New york " + paris.ToTimeZone(dateLocal, ny));

The previous code generates the following output :

Local time at paris : 05/01/2011 10:00:00 UTC : 05/01/2011 09:00:00
Local time at new york : 05/01/2011 04:00:00
Paris : 05/01/2011 10:00:00 New york : 05/01/2011 04:00:00

Retrieve TimeZone

TzTimeZone can be retrieve directly by members of class Afk.ZoneInfo.Zones.

TzTimeZone timeZone = Afk.ZoneInfo.Zones.America.New_York;

However you can use the static functions of class Afk.ZoneInfo.TzTimeInfo to enumerate all available zones.

Function Description
GetCountries Gets all countries
GetCountriesCode Gets all countries code
GetZone Gets the TzTimeZone related to the zone name specified
GetZones Gets all TzTimeZone
GetZoneNames Gets all timezone name
FindSystemTzTimeZoneById Gets the TzTimeZone related to the windows id specified
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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
4.2.0 13,721 12/27/2023
4.1.0 50,905 10/31/2022
4.0.0 3,480 7/28/2022
3.0.0 48,442 11/10/2019
2.4.0 54,380 8/21/2018
2.0.0 1,774 8/16/2017
1.4.0 2,898 12/20/2015

Upgrade to 2023d database