Hello, I think there's a small regression in coreutils 8.25 date command with regards to timezone printing on a machine without native 'timezone_t'. Example:
$ uname -a SunOS unstable10x 5.10 Generic_147441-19 i86pc i386 i86pc $ export TZ=Asia/Tokyo $ ./coreutils-8.24/src/date +%Z JST $ ./coreutils-8.25/src/date +%Z [[[empty line]]] I suspect it has something to do with this commit: commit 037e3b9847feb46cf6b58d99ce960d3987faaf52 date: 2015-07-24 01:49:31 (GMT) subject: build: fprintftime/nstrftime API changes configuration values on this machine: $ ggrep -E 'TZ|ZONE' lib/config.h #define GETTIMEOFDAY_TIMEZONE void #define HAVE_DECL_TZNAME 1 #define HAVE_RUN_TZSET_TEST 1 /* #undef HAVE_STRUCT_TM_TM_ZONE */ /* #undef HAVE_TIMEZONE_T */ `HAVE_STRUCT_TM_TM_ZONE' instead. */ /* #undef HAVE_TM_ZONE */ #define HAVE_TZNAME 1 #define HAVE_TZSET 1 /* #undef TZSET_CLOBBERS_LOCALTIME */ Trying to debug, I see the following: 1. in 'date.c', show_date() calls fprintftime (in ./lib/strftime.c). The values upon entry are: fprintftime (s=0x8079c10 <_iob+16>, format=0x8047ccd "%Z", tp=0xfef30200, tz=0x807b028, ns=446195784) at lib/strftime.c:1465 (gdb) p *tz $6 = {next = 0x0, tzname_copy = {0x0, 0x0}, tz_is_set = 1 '\001', abbrs = 0x807b035 "Asia/Tokyo"} 2. stepping through ./lib/strftime.c:445 has this: 445 char **tzname_vec = tzname; (gdb) p tzname $10 = {0xfef302c4 "JST", 0xfef30304 "JDT"} 3. ./lib/strftime.c:484 has this, which sets tzname_vec to nulls (from 'tz', originating from 'tzalloc'): (gdb) n 484 tzname_vec = tz->tzname_copy; (gdb) n 493 if (!(zone && *zone) && tp->tm_isdst >= 0) { (gdb) p tzname_vec $3 = (char **) 0x807b02c (gdb) p *tzname_vec $4 = 0x0 (gdb) p zone $5 = 0x0 (gdb) n 494 zone = tzname_vec[tp->tm_isdst != 0]; (gdb) n 496 if (! zone) (gdb) p zone $6 = 0x0 (gdb) n 497 zone = ""; >From this point on, 'zone' is an empty string, and that's what is printed by 'date'. Not sure where to start at fixing it, but I hope the attached patch can be used to test it. Happy to test things further if needed. regards, - assaf
From e87ceb59821cd0daaa951e0ed9715885bdd99088 Mon Sep 17 00:00:00 2001 From: Assaf Gordon <assafgor...@gmail.com> Date: Wed, 16 Mar 2016 23:23:19 -0400 Subject: [PATCH] tests: test date %Z behaviour * tests/misc/date.pl: ensure %Z format prints correct values. --- tests/misc/date.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/misc/date.pl b/tests/misc/date.pl index 2d19254..f6e0e28 100755 --- a/tests/misc/date.pl +++ b/tests/misc/date.pl @@ -218,6 +218,10 @@ my @Tests = # Don't recognize %:z with a field width between the ':' and the 'z'. ['tz-5wf', '+%:8z', {OUT=>"%:8z"}, {ENV=>'TZ=XXX0:01'}], + # Test alphabetic timezone abbrv + ['tz-6', '+%Z', {OUT=>"UTC"}], + ['tz-7', '+%Z', {OUT=>"JST"}, {ENV=>'TZ=Asia/Tokyo'}], + ['ns-relative', '--iso=ns', "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'", -- 2.0.4