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: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-developers at cygwin dot com
- Cc: David Sastre <d dot sastre dot medina at gmail dot com>
- Date: Sun, 29 Jan 2012 10:46:26 +0100
- 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> <20120127181643.GB22207@ednor.casa.cgf.cx> <20120127193855.GF22449@calimero.vinschen.de>
- Reply-to: cygwin-developers at cygwin dot com
On Jan 27 20:38, Corinna Vinschen wrote:
> On Jan 27 13:16, Christopher Faylor wrote:
> > On Fri, Jan 27, 2012 at 05:39:52PM +0100, Corinna Vinschen wrote:
> > >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`
>
> Good idea. I try to come up with something over the weekend.
I called it "tzset" and added it to our utils. Starting with XP, it
uses the geographical location setting of the user to find the right
mapping, rather than the locale setting. Only on Windows 2000 which
doesn't know about the user's geographical location, or if fetching
the geographical location fails, it falls back to the user's locale.
Tested on Windows 2000, XP, 7.
Apart from that, we should add profile.d scripts for sh and csh to set
TZ using this tool. Ideally as part of the base-files package. Which
reminds me that lang.{sh,csh} should set LANG to the output of locale
-sU or locale -uU.
David, any chance you could do that right after we release 1.7.10?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat