2
votes

I'm having trouble mapping joda time zones to windows time zones.

I use the xml of CLDR mappings, and it works for most of the translations.

nevertheless, it doesn't have values for several joda time zones:

America/Indiana/Indianapolis, BST, Australia/Victoria, Universal, Australia/NSW, America/Fort_Wayne, Africa/Asmara, America/Kentucky/Louisville, Asia/Kashgar, US/Pacific, Australia/West, Australia/Queensland, Australia/South, US/Eastern, US/Central, US/Arizona, Australia/Tasmania, NZ, US/Mountain, Australia/Eucla, GMT, Japan, CAT, Etc/GMT+0, CST, PST, EST, Australia/Canberra, Mexico/General, Israel, Canada/Eastern, Etc/GMT+9, Canada/Central, Australia/North

Where can I find the mapping between these joda timezones to windows timezones?

1
Are you looking for an explanation of how to map those using the cldr and tzdb sources? Or are you looking for C# code to do the translation?Matt Johnson-Pint
I'm looking for a way to map all joda time zones including the ones in the question. Maybe something like the CLDR, but includes the missing joda time zones (CLDR doesn't have mapping for the specified joda time zones)....user1028741

1 Answers

1
votes

Using pure CLDR data:

  • Check for the zone in the /common/bcp47/timezone.xml file.

    If it's not the first entry in the alias field, then use the first entry. Example:

    <type name="aumel" description="Melbourne, Australia"
                       alias="Australia/Melbourne Australia/Victoria"/>
    

    You can see Australia/Victoria as the second item, so it is an alias to Australia/Melbourne. Note that CLDR's canonical zones are not exactly matched to TZDB's definition of canonical, so use these CLDR mappings - not the link entries from tzdb.

  • Now check the /common/supplemental/windowsZones.xml file. Example:

    <mapZone other="AUS Eastern Standard Time" territory="AU"
             type="Australia/Sydney Australia/Melbourne"/>
    

    The type field contains one or more tzdb zones. The other field contains the corresponding Windows zone.

  • Be aware that not all tzdb zones have a valid corresponding Windows zone, and some are not perfect mappings.

    • Example of imperfect mapping: America/Havana => Eastern Standard Time

      • DST transition days align, but Cuba transitions at midnight instead of 2 AM
    • Example of unmappable zone: Australia/Lord_Howe

      • Exists in timezone.xml, but not in windowsZones.xml.
      • There is currently no Windows time zone entry for this location.
  • You have a few items in your list (BST, CAT, CST, PST) that are not valid tzdb zones, even by Joda-Time's list. These could be abbreviations or rule names, but they are not zone identifiers.