GeoTimeZone

repository·main·Indexed 42 days ago

https://github.com/mattjohnsonpint/geotimezone

A .NET library that provides IANA time zone identifiers based on latitude and longitude coordinates. Supports .NET 6+, .NET Core 2.0+, and .NET Framework 4.6.2+.

Tokens
309
Snippets
2
Records
4
Agent score
4%

What's inside GeoTimeZone

  1. Convert IANA time zone IDs to Windows time zone IDs

    main

    GeoTimeZone returns IANA time zone IDs. If your application requires Windows time zone IDs, you should use the TimeZoneConverter library.

    Specifically, pass the string returned by GeoTimeZone into:

    • TZConvert.IanaToWindows to get a Windows ID string.
    • TZConvert.GetTimeZoneInfo to obtain a platform-neutral TimeZoneInfo object.
  2. Get an IANA time zone ID from coordinates

    main

    Use the TimeZoneLookup.GetTimeZone method to retrieve an IANA time zone identifier based on latitude and longitude. The method returns a Task<string>, so you must await the result or access .Result.

    string tz = TimeZoneLookup.GetTimeZone(50.4372, -3.5559).Result;  // "Europe/London"