This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
POSIX timezone (was Re: date command shows time 20 minutes into future)
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-developers at cygwin dot com
- Date: Fri, 27 Jan 2012 17:39:52 +0100
- Subject: POSIX timezone (was Re: date command shows time 20 minutes into future)
- References: <CAPJ9Yc_tZLi+4ba_0esNzwb5pgHKJvv3cky72g2vSd17udhgrg@mail.gmail.com> <20120127124827.GA22449@calimero.vinschen.de> <4F22BAB4.6040607@hones.org.uk> <20120127160250.GB22449@calimero.vinschen.de>
- Reply-to: cygwin-developers at cygwin dot com
On Jan 27 17:02, Corinna Vinschen wrote:
> On Jan 27 14:54, Cliff Hones wrote:
> > I think the CEST comes from Windows. If you don't have TZ set,
> > I think Cygwin turns the timezone names Windows provides into
> > abbreviated names by taking the leading letters.
> >
> > So Windows "Central European Standard Time" => CEST
> > and "Central European Daylight Time" => CEDT
> >
> > I've never liked this - arguably Windows is wrong to use non-standard
> > naming for the timezones. It's even worse for us in the UK - we get
> > GMTST and GMTDT - ugh. [UK may be a little unusual, but perfectly
> > reasonable in using GMT and BST.]
>
> Uh, right. Thanks for reminding me. The problem is of course that we
> only have this information source, if the environment variable TZ isn't
> set. Worse, the Windows timezone name is potentially language dependent.
> Therefore a simple translation table is not sufficient. It would require
> some registry scanning. Setting TZ is much simpler.
Does anybody here think it would be a good idea if Cygwin generates a
valid TZ setting if TZ isn't set in the environment when started from a
native process?
There is a table from Windows timezone key names as used in the registry
to TZIDs as used by POSIX on unicode.org(*). The mechanism in pseudo
code would look like this:
- TZ set? All is well.
- Otherwise checkout HKLM/SYSTEM/CCS/Control/TimeZoneInformation
- Does value TimeZoneKeyName exist?
Yes (Vista and later) -> Use as keyname
No (pre-Vista) -> x = StandardName
- Iterate over keys under HKLM/Software/MSFT/Win NT/CV/TimeZones
- If x[0] == '@' test if x == MUI_Std
else test if x == Std
if so, keyname = name of containing key
- GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, region);
- Map keyname and region to TZID according to table from unicode.org.
- set TZ=mapped_TZID
Advantage: Always having a valid POSIX timezone information
Disadvantage: Takes time every time we start up the first Cygwin process
in a process tree. Not a lot on Vista and later, though.
Corinna
(*) http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/zone_tzid.html
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat