GNU bug report logs - #44960
date --expose-flags

Previous Next

Package: coreutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Mon, 30 Nov 2020 13:23:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>, 44960 <at> debbugs.gnu.org
Subject: bug#44960: date --expose-flags
Date: Mon, 30 Nov 2020 19:10:57 +0000
On 30/11/2020 13:21, 積丹尼 Dan Jacobson wrote:
> I got this brilliant idea.
> Let's say one likes the output of
> 
> $ date --iso-8601=seconds
> 2020-11-30T21:15:47+08:00
> 
> but wants to know "how you did it?"
> 
> Hmmm, no assistance from
> $ date --iso-8601=seconds --debug
> 2020-11-30T21:15:50+08:00
> 
> Ah, if only there were a:
> $ date --iso-8601=seconds --expose-flags
> date +%Y-%m-%dT%H:%M:%S%z
> 
> Then one needn't use trial and error to figure out the template being
> used behind the scenes!

A useful idea.
I'll add that with the following.

thanks,
Pádraig

commit 17af226bd80db3376e9137384c1ba14a8d94c434 (HEAD -> master)
Author: Pádraig Brady <P <at> draigBrady.com>
Date:   Mon Nov 30 19:06:59 2020 +0000

    date: with --debug, output the format used

    * src/date.c (main): The format can be determined from
    --options or the locale, so it's useful to output
    the format string being used.
    Addresses https://bugs.gnu.org/44960

diff --git a/src/date.c b/src/date.c
index c33fa3fc5..20af782df 100644
--- a/src/date.c
+++ b/src/date.c
@@ -505,6 +505,9 @@ main (int argc, char **argv)
         }
     }

+  if (parse_datetime_flags & PARSE_DATETIME_DEBUG)
+    error (0, 0, _("using date format %s"), quote (format));
+
   char const *tzstring = getenv ("TZ");
   timezone_t tz = tzalloc (tzstring);




This bug report was last modified 3 years and 83 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.