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: Paul Eggert
Subject: Re: date not parsing full iso-8601
Date: Thu, 15 Sep 2005 11:52:55 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Jim Meyering <address@hidden> writes:

> 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.

Hmm, RFC 3339 requires the leading zero in "+07:00".  Some people like
"+7" and they can have that by specifying a smaller width.  I agree
that "+007" would be overkill (no pun intended), but my impression is
that the code won't easily generate both "+07" and " +07".

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

Thanks for catching that.  I tuned the patch slightly by installing
this further patch.

2005-09-15  Paul Eggert  <address@hidden>

        * strftime.c (my_strftime): Rewrite the previous change slightly,
        to make it a bit faster and (I hope) clearer.

--- strftime.c  14 Sep 2005 16:10:38 -0000      1.91
+++ strftime.c  15 Sep 2005 18:47:56 -0000      1.92
@@ -492,7 +492,7 @@ my_strftime (CHAR_T *s, size_t maxsize, 
       int width = -1;
       bool to_lowcase = false;
       bool to_uppcase = false;
-      size_t colons = 0;
+      size_t colons;
       bool change_case = false;
       int format_char;
 
@@ -643,19 +643,6 @@ 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 == L_(':') && q - f < 3; q++)
-         ; /* empty */
-       if (*q == L_('z'))
-         {
-           colons = q - f;
-           f = q;
-         }
-      }
-
       /* Now do the specified format.  */
       format_char = *f;
       switch (format_char)
@@ -1320,7 +1307,20 @@ my_strftime (CHAR_T *s, size_t maxsize, 
 #endif
          break;
 
+       case L_(':'):
+         /* :, ::, and ::: are valid only just before 'z'.
+            :::: etc. are rejected later.  */
+         for (colons = 1; f[colons] == L_(':'); colons++)
+           continue;
+         if (f[colons] != L_('z'))
+           goto bad_format;
+         f += colons;
+         goto do_z_conversion;
+
        case L_('z'):
+         colons = 0;
+
+       do_z_conversion:
          if (tp->tm_isdst < 0)
            break;
 




reply via email to

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