[PATCH] test-parse-date: fix timezone name used to test local time with DST
Sébastien Brissaud
sebastien at brissaud.name
Mon Feb 15 02:04:40 EST 2016
On 2016-02-13 09:19, Yuya Nishihara wrote:
> On Sat, 13 Feb 2016 07:24:11 +0100, Sébastien Brissaud wrote:
>> On 2016-02-11 07:29, Yuya Nishihara wrote:
>> > http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
Re-reading this page, DST start/end aren't optional and need to be
specified.
$ zdump -v /usr/share/zoneinfo/PST8PDT | cut -d ' ' -f 3- | grep 2006
Sun Apr 2 09:59:59 2006 UT = Sun Apr 2 01:59:59 2006 PST isdst=0
gmtoff=-28800
Sun Apr 2 10:00:00 2006 UT = Sun Apr 2 03:00:00 2006 PDT isdst=1
gmtoff=-25200
Sun Oct 29 08:59:59 2006 UT = Sun Oct 29 01:59:59 2006 PDT isdst=1
gmtoff=-25200
Sun Oct 29 09:00:00 2006 UT = Sun Oct 29 01:00:00 2006 PST isdst=0
gmtoff=-28800
Thus 'PST+8PDT' is invalid and should be, for 2006,
'PST+8PDT,M4.1.0,M10.5.0'.
> 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
On my system, '/usr/share/zoneinfo/posixrules' defines time in the
EST/EDT timezone.
$ zdump -v /usr/share/zoneinfo/posixrules | cut -d ' ' -f 3- | grep 2006
Sun Apr 2 06:59:59 2006 UT = Sun Apr 2 01:59:59 2006 EST isdst=0
gmtoff=-18000
Sun Apr 2 07:00:00 2006 UT = Sun Apr 2 03:00:00 2006 EDT isdst=1
gmtoff=-14400
Sun Oct 29 05:59:59 2006 UT = Sun Oct 29 01:59:59 2006 EDT isdst=1
gmtoff=-14400
Sun Oct 29 06:00:00 2006 UT = Sun Oct 29 01:00:00 2006 EST isdst=0
gmtoff=-18000
And that is certainly why my system correctly applied DST with e.g.
TZ='PST+5PDT' but not with TZ='PST+8PDT'.
> 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?
TZ can be defined to a timezone file (TZ=":PST8PDT") but this file is
now expected to be present on the system running the test.
(https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html#TZ-Variable
defines the third format as ':characters' but the implementation
silently ignore it:
https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzset.c;h=8bc7a2e05bb83e9e6e37d6f2b6db2d6ad49b9b8b;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l424))
We can also define TZ by using the second format
(TZ="PST+8PDT+7,M4.1.0/02:00:00,M10.5.0/02:00:00") and thus only
requiring the system running the test to be POSIX compliant.
I prefer the second option which I found more explicit about the offset
definition and DST transitions.
What did you think?
--
sbr
More information about the Mercurial-devel
mailing list