From e361bff8a5ef97fd784a79ce789d8ac6c7e20fc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Mon, 30 Nov 2020 19:06:59 +0000 Subject: [PATCH] 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 --- src/date.c | 3 +++ tests/misc/date-debug.sh | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/date.c b/src/date.c index c33fa3fc5e..27a1f1335a 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 362dc8d195..9978ab11d6 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 -- 2.47.2