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: Wed, 14 Sep 2005 00:04:24 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> All I could think of when the problem first came up was %Ez, since %E
> specifies alternate format, but that doesn't really fit the three formats
> you provided, so your choice seems great to me.

Thanks.  Also, %E is supposed to be about locales, but this stuff is
locale-independent, so it didn't seem wise in that respect either.

>>      (TIME_SOEC_HOURS, TIME_SPEC_MINUTES): Must be at end now, so put
>               ^^^^
> typo in the changelog

Thanks; fixed.

> What about du, pinky, pr, stat, and who, which also use a form of
> strftime?  And what about the FIXME in uptime to use strftime?

You're right, du and pr are affected; I'll note that.
The others aren't affected since the user can't specify the format.
The FIXME can wait for someone who's inspired to fix it....

> Now that -I is deprecated, should it print a warning to stderr?  Or just
> silently work for a couple of years until it is disabled?

For now let's leave it alone.  Maybe later we can have it issue a
warning, and remove it still later.  No rush.

> TIMESPEC was optional for -I; should it be optional for rfc-3339 as well?

Yes, but that's a future extension, when we can get around to when
supporting clock resolution is reliable.  I'd like plain --rfc-3339
(-i) to output to the available resolution.  But this is a bit tricky.

> I think the description of :, ::, and ::: would fit better in the optional
> flags section below, rather than having to respace all the interpreted
> %<letter> sequence listings because you listed them with %z.

Hmm, could be.  Still, it'd be tricky there too.

> Where are the tests for %::z and %:::z?

Thanks for reminding me.  I added some, which found a bug, which I fixed.

I installed this.  Thanks again for your quick and detailed review.

Index: ChangeLog
===================================================================
RCS file: /fetish/cu/ChangeLog,v
retrieving revision 1.1437
diff -p -u -r1.1437 ChangeLog
--- ChangeLog   13 Sep 2005 22:43:11 -0000      1.1437
+++ ChangeLog   14 Sep 2005 06:56:38 -0000
@@ -19,11 +19,11 @@
        Autoconf 2.59.
 
        * NEWS: date has a new --rfc-3339 option, and the old --iso-8601
-       option is deprecated.  date and ls also have new time format
+       option is deprecated.  date, du, ls, and pr also have new time format
        specifiers %:z, %::z, %:::z.
        * src/date.c (TIME_SPEC_DATE): No longer needs to be nonzero, so
        remove the "=1".
-       (TIME_SOEC_HOURS, TIME_SPEC_MINUTES): Must be at end now, so put
+       (TIME_SPEC_HOURS, TIME_SPEC_MINUTES): Must be at end now, so put
        them there.
        (time_spec_string, time_spec): Hours and minutes must be at
        start now, so put them there.
@@ -39,7 +39,7 @@
        (show_date): Assume format arg is not NULL, which is the case
        now.  The default code is moved to 'main'.  This simplifies things
        and allows the default to be calculated just once.
-       * tests/misc/date: Add tests for --rfc-3339.
+       * tests/misc/date: Add tests for --rfc-3339, %:z, %::z, %:::z.
 
 2005-09-13  Jim Meyering  <address@hidden>
 
Index: NEWS
===================================================================
RCS file: /fetish/cu/NEWS,v
retrieving revision 1.309
diff -p -u -r1.309 NEWS
--- NEWS        13 Sep 2005 22:07:34 -0000      1.309
+++ NEWS        14 Sep 2005 06:56:38 -0000
@@ -184,8 +184,8 @@ GNU coreutils NEWS                      
 
   date accepts the new option --rfc-3339=TIMESPEC.  The old --iso-8602 (-I)
   option is deprecated; it still works, but new applications should avoid it.
-  date and ls's time formats now support new %:z, %::z, %:::z specifiers
-  for numeric time zone offsets like -07:00, -07:00:00, and -07.
+  date, du, ls, and pr's time formats now support new %:z, %::z, %:::z
+  specifiers for numeric time zone offsets like -07:00, -07:00:00, and -07.
 
   dd has new iflag= and oflag= flags "binary" and "text", which have an
   effect only on nonstandard platforms that distinguish text from binary I/O.
Index: lib/strftime.c
===================================================================
RCS file: /fetish/cu/lib/strftime.c,v
retrieving revision 1.88
diff -p -u -r1.88 strftime.c
--- lib/strftime.c      13 Sep 2005 22:08:18 -0000      1.88
+++ lib/strftime.c      14 Sep 2005 06:56:38 -0000
@@ -1372,7 +1372,7 @@ my_strftime (CHAR_T *s, size_t maxsize, 
                DO_TZ_OFFSET (6, diff < 0, 04, hour_diff * 100 + min_diff);
 
              case 2: tz_hh_mm_ss: /* +hh:mm:ss */
-               DO_TZ_OFFSET (9, diff < 0, 044,
+               DO_TZ_OFFSET (9, diff < 0, 024,
                              hour_diff * 10000 + min_diff * 100 + sec_diff);
 
              case 3: /* +hh if possible, else +hh:mm, else +hh:mm:ss */
Index: tests/misc/date
===================================================================
RCS file: /fetish/cu/tests/misc/date,v
retrieving revision 1.13
diff -p -u -r1.13 date
--- tests/misc/date     13 Sep 2005 22:09:03 -0000      1.13
+++ tests/misc/date     14 Sep 2005 06:56:38 -0000
@@ -183,6 +183,16 @@ my @Tests =
      ['ns-max32-r', '--rfc-3339=ns', '-d "2038-01-19 03:14:07.999999999"',
       {OUT=>"2038-01-19 03:14:07.999999999+00:00"}],
 
+     ['tz-1', '+%:::z', {OUT=>"-12:34:56"}, {ENV=>'TZ=XXX12:34:56'}],
+
+     ['tz-2', '+%:::z', {OUT=>"+12:34:56"}, {ENV=>'TZ=XXX-12:34:56'}],
+
+     ['tz-3', '+%::z', {OUT=>"+01:02:03"}, {ENV=>'TZ=XXX-1:02:03'}],
+
+     ['tz-4', '+%:::z', {OUT=>"+12"}, {ENV=>'TZ=XXX-12'}],
+
+     ['tz-5', '+%:z', {OUT=>"-00:01"}, {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]