diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-01-20 18:24:02 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-01-20 18:24:54 -0800 |
commit | b14be5085cd1aefd473a000456b21270e6070711 (patch) | |
tree | e15813f9be5eb1de322aac2ccae736ce3d029d22 /src | |
parent | 7cecdd6d69ea6981f93c2f15918c10f2e7af14cd (diff) | |
download | coreutils-b14be5085cd1aefd473a000456b21270e6070711.tar.xz |
date: fix TZ= regression
Problem reported by Paul Wise for Debian, in:
https://bugs.debian.org/851934
This is fallout from the fix for GNU Bug#23035.
* src/date.c (batch_convert): New args TZ and TZSTRING.
All uses changed.
(batch_convert, main): Adjust to parse_datetime2 API change.
(main): Allocate time zone object.
* tests/misc/date-debug.sh: Fix incorrect test case,
caught by the fix.
* tests/misc/date.pl: Test the fix.
Diffstat (limited to 'src')
-rw-r--r-- | src/date.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/date.c b/src/date.c index eed09016d..eb7c624e3 100644 --- a/src/date.c +++ b/src/date.c @@ -286,7 +286,8 @@ Show the local time for 9AM next Friday on the west coast of the US\n\ Return true if successful. */ static bool -batch_convert (const char *input_filename, const char *format, timezone_t tz) +batch_convert (const char *input_filename, const char *format, + timezone_t tz, char const *tzstring) { bool ok; FILE *in_stream; @@ -320,7 +321,8 @@ batch_convert (const char *input_filename, const char *format, timezone_t tz) break; } - if (! parse_datetime2 (&when, line, NULL, parse_datetime_flags)) + if (! parse_datetime2 (&when, line, NULL, + parse_datetime_flags, tz, tzstring)) { if (line[line_length - 1] == '\n') line[line_length - 1] = '\0'; @@ -502,10 +504,11 @@ main (int argc, char **argv) } } - timezone_t tz = tzalloc (getenv ("TZ")); + char const *tzstring = getenv ("TZ"); + timezone_t tz = tzalloc (tzstring); if (batch_file != NULL) - ok = batch_convert (batch_file, format, tz); + ok = batch_convert (batch_file, format, tz, tzstring); else { bool valid_date = true; @@ -545,7 +548,8 @@ main (int argc, char **argv) if (set_datestr) datestr = set_datestr; valid_date = parse_datetime2 (&when, datestr, NULL, - parse_datetime_flags); + parse_datetime_flags, + tz, tzstring); } } |