This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: POSIX timezone (was Re: date command shows time 20 minutes into future)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]