]> git.ipfire.org Git - thirdparty/coreutils.git/commit
date ls pr: fix time zone abbrs on SysV platforms
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Mar 2016 17:35:18 +0000 (10:35 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Mar 2016 17:36:33 +0000 (10:36 -0700)
commitdf88fce71651afb2c3456967a142db0ae4bf9906
treeaa18160fb6d2ef669fcfc04e914da9d10b649287
parentc18b3699e1b8c4ad2739761f2b9c306ff2303322
date ls pr: fix time zone abbrs on SysV platforms

The problematic code computed a struct tm in one time zone, and
then printed it or converted it to a string in another.  To be
portable the same time zone needs to be used for both operations.
On GNU platforms this is not an issue, but incorrect output can be
generated on System V style platforms like AIX where time zone
abbreviations are available only in the 'tzname' global variable.
Problem reported by Assaf Gordon in: http://bugs.gnu.org/23035
* NEWS: Document the bug.
* src/date.c (show_date):
* src/ls.c (long_time_expected_width, print_long_format):
* src/pr.c (init_header):
* src/stat.c (human_time): Use localtime_rz instead of localtime,
so that the time zone information is consistent for both localtime
and time-formatting functions like fprintftime and nstrftime.  For
'stat' this change is mostly just a code cleanup but it also
causes stat to also print nanoseconds when printing time stamps
that are out of localtime range, as this is more consistent with
what other programs do.  For programs other than 'stat' this fixes
bugs with time zone formats that use %Z.
* src/du.c, src/pr.c (localtz): New static var.
(main): Initialize it.
* src/du.c (show_date): New time zone argument, so that localtime
and fprintftime use the same time zone information.  All callers
changed.
* tests/misc/time-style.sh: New file.
* tests/local.mk (all_tests): Add it.
* tests/misc/date.pl: Test alphabetic time zone abbreviations.
NEWS
src/date.c
src/du.c
src/ls.c
src/pr.c
src/stat.c
tests/local.mk
tests/misc/date.pl
tests/misc/time-style.sh [new file with mode: 0755]