TimeZoneKit 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package TimeZoneKit --version 1.0.3
                    
NuGet\Install-Package TimeZoneKit -Version 1.0.3
                    
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="TimeZoneKit" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeZoneKit" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="TimeZoneKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TimeZoneKit --version 1.0.3
                    
#r "nuget: TimeZoneKit, 1.0.3"
                    
#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.
#:package TimeZoneKit@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TimeZoneKit&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=TimeZoneKit&version=1.0.3
                    
Install as a Cake Tool

NuGet Publish to NuGet

TimeZoneKit

A simple, intuitive timezone library for .NET that makes working with timezones actually enjoyable.

Why TimeZoneKit?

  • 🎯 Simple API - Easier than NodaTime, more powerful than TimeZoneConverter
  • 🌍 Geographic Lookup - Find timezones by city, coordinates, or country
  • 💼 Business Hours - Built-in business hours and meeting time calculations
  • 🔄 Smart Parsing - Parse timezones from abbreviations, names, or offsets
  • 🌐 Localization - Display names in multiple languages
  • Fast - Cached lookups and optimized for performance
  • 📦 Zero Dependencies - Only requires System.Text.Json
  • 🎨 Cross-Platform - Works on Windows, Linux, and macOS

Installation

dotnet add package TimeZoneKit

Or via NuGet Package Manager:

Install-Package TimeZoneKit

Quick Start

using TimeZoneKit;
using TimeZoneKit.Extensions;

// Simple conversion
var nyTime = DateTime.UtcNow.ToTimeZone("America/New_York");

// Parse various formats
var tz = TimeZoneKit.Parse("EST");           // Abbreviation
var tz2 = TimeZoneKit.Parse("New York");     // City name
var tz3 = TimeZoneKit.Parse("GMT-5");        // Offset

// Check business hours
var isOpen = DateTime.Now.IsBusinessHour("America/New_York");

// Find meeting times across timezones
var slots = TimeZoneKit.FindMeetingTime(
    new[] { "America/New_York", "Europe/London", "Asia/Tokyo" },
    new TimeRange(9, 17),
    DateTime.Today
);

Features

1. Simple Timezone Conversion

// Extension methods for DateTime
var utcTime = DateTime.UtcNow;
var nyTime = utcTime.ToTimeZone("America/New_York");
var londonTime = utcTime.ToTimeZone("Europe/London");

// Static methods
var converted = TimeZoneKit.Convert(dateTime, "America/New_York");
var utc = TimeZoneKit.ToUtc(localTime, "EST");

// Convert between timezones
var tokyoTime = nyTime.ToTimeZone("America/New_York", "Asia/Tokyo");

2. Smart Timezone Parsing

TimeZoneKit can parse timezones from multiple formats:

// Abbreviations
var tz1 = TimeZoneKit.Parse("EST");
var tz2 = TimeZoneKit.Parse("PST");
var tz3 = TimeZoneKit.Parse("GMT");

// City names
var tz4 = TimeZoneKit.Parse("New York");
var tz5 = TimeZoneKit.Parse("London");
var tz6 = TimeZoneKit.Parse("Tokyo");

// Offset strings
var tz7 = TimeZoneKit.Parse("GMT-5");
var tz8 = TimeZoneKit.Parse("UTC+9");

// IANA timezone IDs
var tz9 = TimeZoneKit.Parse("America/New_York");

// Windows timezone IDs
var tz10 = TimeZoneKit.Parse("Eastern Standard Time");

// Safe parsing
if (TimeZoneKit.TryParse("EST", out var tzInfo))
{
    Console.WriteLine($"Parsed: {tzInfo.DisplayName}");
}

3. IANA ↔ Windows Mapping

// Convert between IANA and Windows timezone IDs
var windowsId = TimeZoneKit.IanaToWindows("America/New_York");
// Returns: "Eastern Standard Time"

var ianaId = TimeZoneKit.WindowsToIana("Eastern Standard Time");
// Returns: "America/New_York"

// Get TimeZoneInfo (works with both formats)
var tzInfo = TimeZoneKit.GetTimeZoneInfo("America/New_York");

4. Geographic Lookup

// Find timezone by city name
var londonTz = TimeZoneKit.FromCity("London");
var tokyoTz = TimeZoneKit.FromCity("Tokyo");

// Get all timezones for a country (ISO 3166-1 alpha-2 code)
var usTimezones = TimeZoneKit.GetByCountry("US");
// Returns: ["America/New_York", "America/Chicago", "America/Denver", ...]

var jpTimezones = TimeZoneKit.GetByCountry("JP");
// Returns: ["Asia/Tokyo"]

// Get timezones by UTC offset
var zones = TimeZoneKit.GetByOffset(TimeSpan.FromHours(-5));
// Returns all timezones with UTC-5 base offset

5. Search and Discovery

// Search for timezones
var results = TimeZoneKit.Search("eastern");
// Returns: ["America/New_York", "America/Detroit", ...]

// Get common timezones (for dropdown lists)
var common = TimeZoneKit.GetCommonTimezones();
// Returns: ["America/New_York", "America/Chicago", "Europe/London", ...]

// Get friendly display names
var displayName = TimeZoneKit.GetFriendlyName("America/New_York");
// Returns: "Eastern Time (US & Canada)"

6. DST Information

// Check if a timezone supports DST
var hasDst = TimeZoneKit.SupportsDst("America/New_York");
// Returns: true

// Check if a specific date/time is in DST
var isDst = TimeZoneKit.IsDaylightSavingTime("America/New_York", DateTime.Now);

// Get the UTC offset at a specific time
var offset = TimeZoneKit.GetOffsetAt("America/New_York", DateTime.Now);
Console.WriteLine($"Current offset: {offset.TotalHours} hours");

// Extension method
var isDst2 = DateTime.Now.IsDaylightSavingTime("America/New_York");

7. Business Hours Support

// Check if current time is during business hours (9 AM - 5 PM weekdays)
var isOpen = DateTime.UtcNow.IsBusinessHour("America/New_York");

// Custom business hours
var isOpen2 = DateTime.UtcNow.IsBusinessHour("America/New_York", startHour: 8, endHour: 18);

// Find next business hour
var nextOpen = DateTime.UtcNow.NextBusinessHour("America/New_York");
Console.WriteLine($"Next business hour: {nextOpen}");

// Advanced: Custom business hours per day
var businessHours = new BusinessHours("America/New_York", 9, 17)
{
    Saturday = new TimeRange(10, 14), // Open Saturdays 10 AM - 2 PM
    Sunday = null // Closed Sundays
};

var isNowOpen = businessHours.IsOpen(DateTime.Now);
var nextAvailable = businessHours.NextAvailableTime(DateTime.Now);

8. Meeting Time Finder

Find time slots when all participants are available across different timezones:

// Find meeting times across multiple timezones
var slots = TimeZoneKit.FindMeetingTime(
    timeZones: new[] { "America/New_York", "Europe/London", "Asia/Tokyo" },
    workingHours: new TimeRange(9, 17), // 9 AM - 5 PM
    date: DateTime.Today
);

foreach (var slot in slots)
{
    Console.WriteLine($"Meeting window: {slot.StartTime} - {slot.EndTime} UTC");
    Console.WriteLine($"Duration: {slot.Duration.TotalHours} hours");

    // See what time this is in each timezone
    Console.WriteLine($"  NY: {slot.GetStartTimeInZone("America/New_York")}");
    Console.WriteLine($"  London: {slot.GetStartTimeInZone("Europe/London")}");
    Console.WriteLine($"  Tokyo: {slot.GetStartTimeInZone("Asia/Tokyo")}");
}

// Advanced: Custom business hours per timezone
var customHours = new[]
{
    new BusinessHours("America/New_York", 9, 17),
    new BusinessHours("Europe/London", 8, 16),
    new BusinessHours("Asia/Tokyo", 10, 18)
};

var customSlots = TimeZoneKit.FindMeetingTime(customHours, DateTime.Today);

Supported Timezones

TimeZoneKit includes comprehensive timezone data for 350+ cities, 60+ countries, and 110+ timezone mappings worldwide:

North America (Complete Coverage)

  • United States: All time zones including EST, CST, MST, PST, Arizona (no DST), Alaska, Hawaii
  • Canada: All provinces from Newfoundland (NST) to Pacific, including unique half-hour zones
  • Mexico: Mexico City, Cancun, Monterrey, Tijuana, and regional variations

Europe (Comprehensive)

  • Western Europe: London, Dublin, Lisbon, and Atlantic islands
  • Central Europe: Paris, Berlin, Rome, Madrid, Amsterdam, Brussels, Zurich, Vienna
  • Northern Europe: Stockholm, Copenhagen, Oslo, Helsinki
  • Eastern Europe: Athens, Istanbul, Moscow, Warsaw, Prague, Budapest, Bucharest
  • Russia: All 11 time zones from Kaliningrad to Kamchatka

Asia (Full Coverage)

  • Middle East: Dubai, Riyadh, Tel Aviv, Beirut, Cairo
  • South Asia: India, Pakistan, Bangladesh, Sri Lanka, Nepal (including unique UTC+5:45)
  • Southeast Asia: Singapore, Bangkok, Kuala Lumpur, Jakarta, Manila, Ho Chi Minh City
  • East Asia: Tokyo, Seoul, Shanghai, Beijing, Hong Kong, Taipei

Pacific & Oceania

  • Australia: All time zones including Perth, Darwin, Adelaide, Brisbane, Sydney, Melbourne, Hobart
  • New Zealand: Auckland, Wellington, Christchurch, and Chatham Islands (UTC+12:45)
  • Pacific Islands: Fiji, Guam, Tonga

Latin America

  • South America: Brazil (4 zones), Argentina (12 zones), Chile, Peru, Colombia, Venezuela
  • Central America: All countries from Panama to Guatemala

Africa

  • Major Hubs: Johannesburg, Cairo, Lagos, Nairobi, Casablanca, Addis Ababa

Special Features

  • ✅ Half-hour offsets (India, Newfoundland, Venezuela, etc.)
  • ✅ Quarter-hour offsets (Nepal at UTC+5:45)
  • ✅ DST and non-DST zones correctly handled
  • ✅ Historical timezone changes supported
  • ✅ Multi-timezone countries fully mapped

API Reference

Core Methods

Method Description
Convert(DateTime, string) Convert DateTime to target timezone
Convert(DateTime, from, to) Convert between two timezones
ToUtc(DateTime, string) Convert to UTC
GetTimeZoneInfo(string) Get TimeZoneInfo for timezone ID

Parsing & Discovery

Method Description
Parse(string) Smart parse from any format
TryParse(string, out TimeZoneInfo) Safe parsing
Search(string) Search timezones by keyword
FromCity(string) Get timezone by city name
GetByCountry(string) Get timezones by country code
GetByOffset(TimeSpan) Get timezones by UTC offset

Mappings & Display

Method Description
IanaToWindows(string) Convert IANA to Windows ID
WindowsToIana(string) Convert Windows to IANA ID
GetFriendlyName(string) Get display name
GetCommonTimezones() Get popular timezones

DST Information

Method Description
SupportsDst(string) Check if timezone has DST
IsDaylightSavingTime(string, DateTime) Check if in DST
GetOffsetAt(string, DateTime) Get UTC offset

Business Hours

Method Description
IsBusinessHour(DateTime, string) Check business hours
NextBusinessHour(DateTime, string) Find next business hour
FindMeetingTime(string[], TimeRange, DateTime) Cross-timezone meetings

Extension Methods

All core methods are available as DateTime extension methods:

dateTime.ToTimeZone(timeZoneId)
dateTime.ToUtc(timeZoneId)
dateTime.GetOffset(timeZoneId)
dateTime.IsDaylightSavingTime(timeZoneId)
dateTime.IsBusinessHour(timeZoneId)
dateTime.NextBusinessHour(timeZoneId)

Target Frameworks

  • .NET 8.0
  • .NET 6.0
  • .NET Standard 2.0 (supports .NET Framework 4.6.2+)

Performance

TimeZoneKit is optimized for performance:

  • Lazy loading - Data files loaded only when needed
  • Thread-safe caching - TimeZoneInfo instances cached using ConcurrentDictionary
  • Embedded resources - No file I/O at runtime
  • Zero allocations in hot paths where possible

Test Coverage

TimeZoneKit is extensively tested with 400+ unit tests covering:

  • Parsing: 100+ tests for abbreviations, city names, IANA IDs, Windows IDs, and offset formats
  • Geographic Lookup: 70+ tests for cities, countries, and offset-based searches
  • Conversions: 20+ tests for timezone conversions, DST transitions, and round-trip accuracy
  • DST Handling: 25+ tests for daylight saving time across multiple regions
  • Business Hours: 30+ tests for business hour calculations and meeting time finding
  • Mapping: 50+ tests for IANA ↔ Windows conversions and display names
  • Search: 15+ tests for search functionality and discovery

All tests passing on .NET 8.0, .NET 6.0, and .NET Standard 2.0.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Acknowledgments

  • IANA Timezone Database
  • Unicode CLDR for localization data
  • Inspired by TimeZoneConverter and NodaTime

Support


Made with ❤️ by Ervis Trupja

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.

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.4 110 1/31/2026
1.0.3 94 1/29/2026
1.0.0 98 1/28/2026

v1.1.0: Massive expansion - 350+ cities (from 80), 60+ countries (from 23), 110+ timezone mappings (from 25), 400+ unit tests (from 81). Comprehensive global coverage including all US/Canada zones, complete European coverage, all 11 Russian time zones, full Asia/Pacific support, and complete Latin America. Added support for half-hour and quarter-hour offsets.