[PATCH] test-parse-date: fix timezone name used to test local time with DST

Yuya Nishihara yuya at tcha.org
Sat Feb 13 03:19:40 EST 2016


On Sat, 13 Feb 2016 07:24:11 +0100, S├ębastien Brissaud wrote:
> On 2016-02-11 07:29, Yuya Nishihara wrote:
> > On Sun, 07 Feb 2016 09:31:22 +0100, S├ębastien Brissaud wrote:
> >> -  $ TZ="PST+8PDT"
> >> +  $ TZ="PST8PDT"
> >>    $ export TZ
> > 
> > It seems "PST+8PDT" is valid.
> > 
> > http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
> 
> > Do you have any problem with "PST+8PDT" ?
> 
> I'm running Debian testing and test-parse-date.t failed with incorrect 
> DST offsets:
> -  Sat Jul 15 13:30:00 2006 -0700
> +  Sat Jul 15 13:30:00 2006 -0800

Hmm, I'm on Debian sid, but I couldn't reproduce the problem.

ii  libc6:amd64    2.21-7       amd64        GNU C Library: Shared libraries
ii  python         2.7.11-1     amd64        interactive high-level object-ori
ii  tzdata         2016a-1      all          time zone and daylight-saving tim

> Setting TZ to PST8PDT make the test pass.
> But as you said earlier 'PST+8PDT' is a valid TZ value.
> 
> In fact it seems to be related as how TZ is managed on my system.
> 
> Testing it directly in a python shell exhibit the same problem:
> Python 2.7.11 (default, Jan 11 2016, 21:04:40)
> [GCC 5.3.1 20160101] on linux2
> >>> os.environ['TZ'] = 'PST+8PDT'
> >>> time.tzset()
> >>> time.tzname
> ('PST', 'PST')
> >>> 
> >>> os.environ['TZ'] = 'PST8PDT'
> >>> time.tzset()
> >>> time.tzname
> ('PST', 'PDT')
> 
> PST8PDT works for me because it's resolved to a timezone file in
> /usr/share/zoneinfo.
> I'll investigate the posix compliancy/configuration of TZ in my system.
> 
> test-parse-date.t is thus correct and my patch is irrelevant.

That said, since "PST+8PDT" does not specify dst start/end, it would depend
on the system zoneinfo files anyway.

  % TZ=PST+8PDT strace date 2>&1 | grep zoneinfo
  open("/usr/share/zoneinfo/PST+8PDT", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
  open("/usr/share/zoneinfo/posixrules", O_RDONLY|O_CLOEXEC) = 3
  % TZ=PST8PDT strace date 2>&1 | grep zoneinfo
  open("/usr/share/zoneinfo/PST8PDT", O_RDONLY|O_CLOEXEC) = 3

https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=8bc7a2e05bb83e9e6e37d6f2b6db2d6ad49b9b8b;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l278

If PST8PDT can provide more stable result, it will be fine to use that TZ
value. Can you resend the patch with updated commit message?


More information about the Mercurial-devel mailing list