This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: POSIX timezone (was Re: date command shows time 20 minutes into future)
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin-developers at cygwin dot com
- Date: Fri, 27 Jan 2012 13:16:43 -0500
- Subject: Re: 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> <20120127163952.GE22449@calimero.vinschen.de>
- Reply-to: cygwin-developers at cygwin dot com
On Fri, Jan 27, 2012 at 05:39:52PM +0100, Corinna Vinschen wrote:
>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.
I think it would be better to have a program in the distro which could
set the timezone from Windows given the above. It could be run when
needed in a startup script, avoiding the need for Cygwin programs to
incur a potentially unneeded performance penalty if TZ is not set.
export TZ=`wintz`
setenv TZ `wintz`
cgf