Twileloop.Timezone 2.0.0

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

// Install Twileloop.Timezone as a Cake Tool
#tool nuget:?package=Twileloop.Timezone&version=2.0.0                

<br /> <div align="center"> <a href="https://github.com/sangeethnandakumar/Twileloop.Timezone"> <img src="https://iili.io/HUQ2pxn.png" alt="Logo" width="80" height="80"> </a>

<h2 align="center"> Twileloop.Timezone </h2> <h4 align="center"> Convert | Migrate | Search </h4>

</div>

About

An easy to use utility wrapper around NodaTime to easily convert timezones from any timezones, countries, offsets, short and long names etc.. while leveraging the powerfull NodaTime and globaliazation.

Note Starting from version v2.0+ and above, This is the official documentation. For older versions, Refer old documentation <a href="https://github.com/sangeethnandakumar/Twileloop.Timezone/blob/master/README_Old.md"> here </a>

License

Twileloop.Timezone is licensed under the MIT License. See the LICENSE file for more details.

This library is absolutely free. If it gives you a smile, A small coffee would be a great way to support my work. Thank you for considering it!

"Buy Me A Coffee"

1. Install Package

dotnet add package Twileloop.Timezone

Supported Features

Status From To
UTC timezone 🡺 System timezone
UTC timezone 🡺 Custom timezone
Custom timezone 🡺 UTC timezone
Custom timezone 🡺 Custom timezone
Timezone Abbreviation 🡺 Timezone Id
Timezone Id 🡺 Timezone Abbreviation
Timezone Id 🡺 Country ISO Codes (Under that timezone)
Country ISO Code 🡺 Timezone Ids (Under that country)
Country Name 🡺 Country ISO Code
Country ISO Code 🡺 Country Name

2. System timezone 🡺 UTC timezone

//System timezone 🡺 UTC timezone
var utcTime = DateTime.UtcNow;

3. UTC timezone 🡺 System timezone

//UTC timezone 🡺 System timezone
var mySystemTime = utcTime.UtcToSystemTimezone();

4. UTC timezone 🡺 Custom timezone

//UTC timezone 🡺 Custom timezone
var japanTime = utcTime.UtcToCustomTimezone("Asia/Tokyo");

5. Custom timezone 🡺 UTC timezone

//Custom timezone 🡺 UTC timezone
var japanTimeInUtc = japanTime.CustomTimezoneToUtc("Asia/Tokyo");

6. Custom timezone 🡺 Custom timezone

//Custom timezone 🡺 Custom timezone
var indianTime = japanTime.MigrateToTimezone("Asia/Tokyo", "Asia/Kolkata");

7. Timezone Abbreviation 🡺 Timezone Id

// Timezone Abbreviation 🡺 Timezone Id
var abbreviation = "IST";
var (displayName, timeZoneIds) = TimezoneHelper.AbbreviationToTimezone(abbreviation);

Console.WriteLine($"Abbreviation: {abbreviation}");
Console.WriteLine($"Full Display Name: {displayName}");
Console.WriteLine("Time Zone Identifiers:");

foreach (var timeZoneIda in timeZoneIds)
{
    Console.WriteLine(timeZoneIda);
}

8. Timezone Id 🡺 Timezone Abbreviation

// Timezone Id 🡺 Timezone Abbreviation
var timeZoneId = "Asia/Kolkata";
var (zoneAbbreviation, zoneDisplayName) = TimezoneHelper.TimezoneToAbbreviation(timeZoneId);

Console.WriteLine($"Time Zone Identifier: {timeZoneId}");
Console.WriteLine($"Abbreviation: {zoneAbbreviation}");
Console.WriteLine($"Full Display Name: {zoneDisplayName}");

9. Timezone Id 🡺 Countries Under Timezone

// Timezone Id 🡺 Country Codes
string timezone = "America/New_York";
List<(string CountryCode, string CountryName)> countriesUnderTimezone  = TimezoneHelper.GetCountriesUnderTimezone(timezone);

Console.WriteLine($"Countries under timezone '{timezone}':");
foreach (var country in countriesUnderTimezone)
{
    Console.WriteLine($"{country.CountryCode} | {country.CountryName}");
}

10. Country ISO Code 🡺 Timezones Under Country

// Country Code 🡺 Timezones
string countryCode = "US";
List<string> timezones = TimezoneHelper.GetTimezonesUnderCountry(countryCode);
Console.WriteLine($"Timezones under country '{countryCode}':");
foreach (string tz in timezones)
{
    Console.WriteLine($"{tz}");
}

11. Country Name 🡺 Country ISO Code

// Country Name 🡺 Country Code
string countryName = "United States";
string isoCountryCode = TimezoneHelper.CountryNameToAbbreviation(countryName);
Console.WriteLine($"Country name '{countryName}' has the abbreviation: {isoCountryCode}");

12. Country ISO Code 🡺 Country Names

// Country Code 🡺 Country Name 
string isoCode = "US";
string fullCountryName = TimezoneHelper.AbbreviationToCountryName(isoCode);
Console.WriteLine($"Abbreviation '{isoCode}' corresponds to the country: {fullCountryName}");

13. Timezones Sharing Same Offset (In Minuits)

//Find timezones sharing same offset (+5:30 is 330 mins)
var timezonesSharingSameOffset = TimezoneHelper.OffsetToTimezones(330);
timezonesSharingSameOffset.ForEach(timeZone =>
{
    Console.WriteLine(timeZone.DisplayName);
});

14. All Timezones

//Get all timezones
var allTimezones = TimezoneHelper.GetAllTimezones();
allTimezones.ForEach(timeZone =>
{
    Console.WriteLine(timeZone.ToString());
});

15. All Countries

//Get all countries
List<(string CountryCode, string CountryName)> allCountries = TimezoneHelper.GetAllCountries();
allCountries.ForEach(country =>
{
    Console.WriteLine($"{country.CountryCode} | {country.CountryName}");
});
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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.

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
2.0.0 5,010 5/17/2023