Long form name of timezone in NodaTime

后端 未结 3 829
灰色年华
灰色年华 2021-01-18 23:56

In NodaTime, how do you find the long form name of a timezone given the tz timezone id?

For example, if I supply \"America/Los_Angeles\", I should get \"Pacific Stan

3条回答
  •  野的像风
    2021-01-19 00:21

    Short answer: https://github.com/barrycarter/bcapps/blob/master/ASTRO/tz2name.txt

    Long answer: As others have noted, you can use CLDR's common/supplemental/metaZones.xml file to map timezones to regions. For example:

                        
                                
                        
    

    maps the timezone "America/Barbados" to the region "Atlantic".

    You can then use common/main/en.xml to convert the region to a timezone name. For example:

                        
                                
                                        Atlantic Time
                                        Atlantic Standard Time
                                        Atlantic Daylight Time
                                
                                
                                        AT
                                        AST
                                        ADT
                                
                        
    

    tells us the names of the timezones (long and short forms) used in the "Atlantic" region.

    This is pretty much a repeat of the other answers, but with direct references to files in question.

提交回复
热议问题