Jeff Muir
Jeff Muir

Reputation: 95

Are Microsoft time zone names in TIME_ZONE_INFORMATION structure ever translated?

The answer appears to be no, however I have seen one customer trace that showed the local time zone name in Spanish. Source of the information is from GetTimeZoneInformation. The document says that these names in the structure will always be English and the user-visible name is coming from a resource file. It would be great to have confirmation either way. To be clear, it is this structure:

typedef struct _TIME_ZONE_INFORMATION {
  LONG       Bias;
  WCHAR      StandardName[32];
  SYSTEMTIME StandardDate;
  LONG       StandardBias;
  WCHAR      DaylightName[32];
  SYSTEMTIME DaylightDate;
  LONG       DaylightBias;
} TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION;

Will StandardName and DaylightName ever be non-English?

Upvotes: 2

Views: 1284

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241808

I'm not sure where you read they were English only. From the MSDN Documentation:

Both StandardName and DaylightName are localized according to the current user default UI language.

Also, on modern Windows, you should mostly be using the DYNAMIC_TIME_ZONE_INFORMATION structure, with APIs such as GetDynamicTimeZoneInformation, instead of the classic GetTimeZoneInformation function. This structure contains the same standard and daylight names, and are localized as well.

When used as intended, these structures are filled with information from the Windows registry, under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. Each entry has four strings that are pertinent:

  • The Std value is the localized name to be used when standard time is in effect. This gets mapped to the StandardName field in the structures.

  • The Dlt value is the localized name to be used when daylight time is in effect. This gets mapped to the DaylightName field in the structures.

  • The Display value is the localized name used to generically represent the time zone entry, and is used when showing a list of time zones - such as in the Windows control panel, or with tzutil.exe on the command line, or with TimeZoneInfo.DisplayName in .NET. It is not part of either Win32 structure.

  • The key of the registry entry is never localized. It is always in English, and is a unique identifier for the time zone. In a DYNAMIC_TIME_ZONE_INFORMATION structure, it corresponds to the TimeZoneKeyName field. In .NET it corresponds to TimeZoneInfo.Id. Also keep in mind that while the key usually matches the English form of the standard name, there are a few exceptions where it does not. Additionally, a specific key's name is guaranteed to never change, while the localized values under it could, in theory.

Here, you can see how the display names look in the Windows control panel in English and in Chinese. Similar localization occurs with the standard and daylight names:

Windows Time Zone Control Panels

And lastly - IMHO these names are quite rubbish in many cases. For example, there is no such thing as "GMT Daylight Time" - it's actually called "British Summer Time". The only good source of localized time zone names is in the CLDR, which you can either consume directly, or through libraries such as ICU in C and Java, or my TimeZoneNames library for .NET.

Upvotes: 4

Related Questions