bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date not parsing full iso-8601


From: Jim Meyering
Subject: Re: date not parsing full iso-8601
Date: Wed, 14 Sep 2005 12:12:24 +0200

Paul Eggert <address@hidden> wrote:
> 2005-09-13  Paul Eggert  <address@hidden>
>
>       * NEWS: date has a new --rfc-3339 option, and the old --iso-8601
>       option is deprecated.  date and ls also have new time format
>       specifiers %:z, %::z, %:::z.

So my threat of incoming fprintftime changes motivated you, Eh?
You got yours in first, so now *I* get to do the merge :-)
But it wasn't too bad, and it turned up a bug.
BTW, I don't like the fact that the new %:z formats zero-fill by default,
when used with a wider field width, but I've left it as-is, for now.

2005-09-14  Jim Meyering  <address@hidden>

        * strftime.c (my_strftime): Parse the colons of %:::z *after* the
        optional field width, not before, so we accept %9:z, not %:9z.

2005-09-14  Jim Meyering  <address@hidden>

        * tests/misc/date (tz-5w, tz-5wf): Test new %:z format with
        a field width.

Index: lib/strftime.c
===================================================================
RCS file: /fetish/cu/lib/strftime.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -p -u -r1.89 -r1.90
--- lib/strftime.c      14 Sep 2005 06:58:08 -0000      1.89
+++ lib/strftime.c      14 Sep 2005 10:02:54 -0000      1.90
@@ -596,11 +596,6 @@ my_strftime (CHAR_T *s, size_t maxsize, 
              pad = *f;
              continue;
 
-             /* This influences the %z format.  */
-           case L_(':'):
-             colons++;
-             continue;
-
              /* This changes textual output.  */
            case L_('^'):
              to_uppcase = true;
@@ -648,6 +643,19 @@ my_strftime (CHAR_T *s, size_t maxsize, 
          break;
        }
 
+      /* Parse the colons of %:::z *after* the optional field width,
+        not before, so we accept %9:z, not %:9z.  */
+      {
+       const CHAR_T *q;
+       for (q = f; *q == ':' && q - f < 3; q++)
+         ; /* empty */
+       if (*q == 'z')
+         {
+           colons = q - f;
+           f = q;
+         }
+      }
+
       /* Now do the specified format.  */
       format_char = *f;
       switch (format_char)
Index: tests/misc/date
===================================================================
RCS file: /fetish/cu/tests/misc/date,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -u -r1.14 -r1.15
--- tests/misc/date     14 Sep 2005 06:58:44 -0000      1.14
+++ tests/misc/date     14 Sep 2005 09:54:15 -0000      1.15
@@ -193,6 +193,11 @@ my @Tests =
 
      ['tz-5', '+%:z', {OUT=>"-00:01"}, {ENV=>'TZ=XXX0:01'}],
 
+     # Accept %:z with a field width before the `:'.
+     ['tz-5w','+%8:z', {OUT=>"-0000:01"}, {ENV=>'TZ=XXX0:01'}],
+     # Don't recognize %:z with a field width between the `:' and the `z'.
+     ['tz-5wf', '+%:8z', {OUT=>"%:8z"}, {ENV=>'TZ=XXX0:01'}],
+
      ['ns-relative',
       '--iso=ns', "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 
sec'",
       {OUT=>"2000-06-15T09:43:58,111111021+0000"}],




reply via email to

[Prev in Thread] Current Thread [Next in Thread]