]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
date: with --debug, show the output format
authorPádraig Brady <P@draigBrady.com>
Mon, 30 Nov 2020 19:06:59 +0000 (19:06 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 1 Dec 2020 13:51:06 +0000 (13:51 +0000)
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
tests/misc/date-debug.sh

index c33fa3fc5e3cdd49c1310220954fe7e96fd64761..27a1f1335a8e90df81528c2246b925009ae21333 100644 (file)
@@ -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)
index 362dc8d195d0d07ed45d8e5c0233d2726db27561..9978ab11d6af757da43e5fb3a8afcffa2d9180b8 100755 (executable)
@@ -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