Project

General

Profile

Actions

Bug #21144

closed

Win32: Use Windows time zone ID as the time zone name if TZ is not set

Added by nobu (Nobuyoshi Nakada) 6 days ago. Updated 4 days ago.

Status:
Closed
Assignee:
Target version:
-
[ruby-core:121083]

Description

Problem

On Windows, the Time#zone uses _tzname provided by the runtime library.
This is obtained by using GetTimeZoneInformation, if the TZ environment variable is not set or empty.

The problem is that the StandardName and DaylightName in that information are for UI, and localized.
This means that these names may vary across different international editions and language packs, even for the same time zone.

Solution

Use the Windows time zone ID by using GetDynamicTimeZoneInformation, which is available since Windows Vista and Windows Server 2008.
Since the TimeZoneKeyName is the registry key of time zones, the above problem does not occur.

This is also mitigate [Bug #20929].
Even it is possible to define non-ascii key name time zone, there is no such name in the standard installations.

Compatibilities etc

  • This also changes the result of Time#inspect, may not be good for ones who prefer the display names for UI.
  • There is no way to restore zone from Marshal data, this does not improve.
  • The PR GH-12765 changes the signature of ruby_reset_timezone() and marks internal use only, but this function is declared in internal/time.h and probably no problem.
Actions #1

Updated by nobu (Nobuyoshi Nakada) 6 days ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) 6 days ago

  • Description updated (diff)

Updated by nobu (Nobuyoshi Nakada) 6 days ago

  • Assignee set to windows
Actions #4

Updated by nobu (Nobuyoshi Nakada) 4 days ago

  • Status changed from Open to Closed

Applied in changeset git|3f07bc76ff6a11232d9f18e5eaa31835c195e8f0.


[Bug #21144] Win32: Use Windows time zone ID if TZ is not set

If the TZ environment variable is not set, the time zone names
retrieved from the system are localized for UI display and may vary
across editions and language packs for the same time zone.
Use the time zone IDs that are invariant across environments instead.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0