diff options
author | Pádraig Brady <P@draigBrady.com> | 2020-11-30 19:06:59 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2020-12-01 13:51:06 +0000 |
commit | e361bff8a5ef97fd784a79ce789d8ac6c7e20fc7 (patch) | |
tree | 3edf4d0de9311c9724fcf780f7d64a78e839b890 | |
parent | 5ed804a9b8d6e7ab217fff5bfb11824f69f03e48 (diff) |
date: with --debug, show the output format
The format can be determined from --options or the locale,
so it's useful to output the format string being used.
* src/date.c (show_date): Show the output format
along with the date being shown.
* tests/misc/date-debug.sh: Adjust accordingly.
Addresses https://bugs.gnu.org/44960
-rw-r--r-- | src/date.c | 3 | ||||
-rwxr-xr-x | tests/misc/date-debug.sh | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/date.c b/src/date.c index c33fa3fc5..27a1f1335 100644 --- a/src/date.c +++ b/src/date.c @@ -584,6 +584,9 @@ show_date (const char *format, struct timespec when, timezone_t tz) { struct tm tm; + if (parse_datetime_flags & PARSE_DATETIME_DEBUG) + error (0, 0, _("output format: %s"), quote (format)); + if (localtime_rz (tz, &when.tv_sec, &tm)) { if (format == rfc_email_format) diff --git a/tests/misc/date-debug.sh b/tests/misc/date-debug.sh index 362dc8d19..9978ab11d 100755 --- a/tests/misc/date-debug.sh +++ b/tests/misc/date-debug.sh @@ -52,6 +52,7 @@ date: timezone: TZ="Asia/Tokyo" environment value date: final: 661095000.000000000 (epoch-seconds) date: final: (Y-M-D) 1990-12-13 13:30:00 (UTC) date: final: (Y-M-D) 1990-12-13 22:30:00 (UTC+09) +date: output format: '%a %b %e %T %z %Y' Thu Dec 13 07:30:00 -0600 1990 EOF @@ -102,6 +103,7 @@ date: timezone: TZ="America/Lima" environment value date: final: 1.000000000 (epoch-seconds) date: final: (Y-M-D) 1970-01-01 00:00:01 (UTC) date: final: (Y-M-D) 1969-12-31 19:00:01 (UTC-05) +date: output format: '%a %b %e %T %z %Y' Wed Dec 31 19:00:01 -0500 1969 EOF @@ -122,6 +124,7 @@ date: timezone: Universal Time date: final: 1356998400.000000000 (epoch-seconds) date: final: (Y-M-D) 2013-01-01 00:00:00 (UTC) date: final: (Y-M-D) 2013-01-01 00:00:00 (UTC+00) +date: output format: '%a %b %e %H:%M:%S %Z %Y' Tue Jan 1 00:00:00 UTC 2013 EOF @@ -149,6 +152,7 @@ date: timezone: Universal Time date: final: 1382400000.000000000 (epoch-seconds) date: final: (Y-M-D) 2013-10-22 00:00:00 (UTC) date: final: (Y-M-D) 2013-10-22 00:00:00 (UTC+00) +date: output format: '%F' 2013-10-22 EOF @@ -178,6 +182,7 @@ date: timezone: Universal Time date: final: 1475280000.000000000 (epoch-seconds) date: final: (Y-M-D) 2016-10-01 00:00:00 (UTC) date: final: (Y-M-D) 2016-10-01 00:00:00 (UTC+00) +date: output format: '%a %b %e %H:%M:%S %Z %Y' Sat Oct 1 00:00:00 UTC 2016 EOF @@ -209,6 +214,7 @@ date: timezone: TZ="America/New_York" environment value date: final: 1480564800.000000000 (epoch-seconds) date: final: (Y-M-D) 2016-12-01 04:00:00 (UTC) date: final: (Y-M-D) 2016-11-30 23:00:00 (UTC-05) +date: output format: '%F' 2016-11-30 EOF @@ -232,6 +238,7 @@ date: timezone: TZ="Europe/Helsinki" environment value date: final: 1323554400.000000000 (epoch-seconds) date: final: (Y-M-D) 2011-12-10 22:00:00 (UTC) date: final: (Y-M-D) 2011-12-11 00:00:00 (UTC+02) +date: output format: '%a %b %e %H:%M:%S %Z %Y' Sun Dec 11 00:00:00 EET 2011 EOF @@ -249,6 +256,7 @@ date: timezone: TZ="Europe/Helsinki" environment value date: final: 1307739600.000000000 (epoch-seconds) date: final: (Y-M-D) 2011-06-10 21:00:00 (UTC) date: final: (Y-M-D) 2011-06-11 00:00:00 (UTC+03) +date: output format: '%a %b %e %H:%M:%S %Z %Y' Sat Jun 11 00:00:00 EEST 2011 EOF @@ -277,6 +285,7 @@ date: timezone: Universal Time date: final: 1302562740.000000000 (epoch-seconds) date: final: (Y-M-D) 2011-04-11 22:59:00 (UTC) date: final: (Y-M-D) 2011-04-11 22:59:00 (UTC+00) +date: output format: '%a %b %e %H:%M:%S %Z %Y' Mon Apr 11 22:59:00 UTC 2011 EOF |