]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
date: use extended format timezone for --iso-8601
authorPádraig Brady <P@draigBrady.com>
Fri, 23 Oct 2015 02:19:18 +0000 (03:19 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 27 Oct 2015 17:25:12 +0000 (17:25 +0000)
* src/date.c (main): Use %:z rather than %z with --iso-8601
as the standard states to consistently use extended format.
Note either format can be parsed by date.
* tests/misc/date.pl: Adjust accordingly.
* doc/coreutils.texi (du invocation): Clarify that "iso"
time styles are only similar to ISO-8601.
(ls invocation): Likewise.
(date invocation): Adjust the comment stating
that only --rfc-3339 output can be parsed by date(1).
* NEWS: Mention the change in behavior.
Reported at http://bugs.debian.org/799479

NEWS
doc/coreutils.texi
src/date.c
tests/misc/date.pl

diff --git a/NEWS b/NEWS
index 0f2874301f3a161cba6b2ae011f7c6a1ed83be47..349577f30afbd63553b02a41b6986359c14a67d8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   base64 no longer supports hex or oct --wrap parameters,
   thus better supporting decimals with leading zeros.
 
+  date --iso-8601 now uses +00:00 timezone format rather than +0000.
+  The standard states to use this "extended" format throughout a timestamp.
+
   df now prefers sources towards the root of a device when
   eliding duplicate bind mounted entries.
 
index 1b81daa99a64a6c8f4bba3409b3a828db62c3596..b1ba097df9236a1ecaa049a11a68e79601224aa4 100644 (file)
@@ -7498,8 +7498,8 @@ files; if you want output columns to line up, you may need to insert
 spaces in one of the two formats.
 
 @item full-iso
-List timestamps in full using ISO 8601 date, time, and time zone
-format with nanosecond precision, e.g., @samp{2002-03-30
+List timestamps in full using ISO 8601 like date, time, and time zone
+components with nanosecond precision, e.g., @samp{2002-03-30
 23:45:56.477817180 -0700}.  This style is equivalent to
 @samp{+%Y-%m-%d %H:%M:%S.%N %z}.
 
@@ -7509,14 +7509,14 @@ explain @command{make}'s behavior, since GNU @command{make}
 uses the full timestamp to determine whether a file is out of date.
 
 @item long-iso
-List ISO 8601 date and time in minutes, e.g.,
+List ISO 8601 like date and time in minutes, e.g.,
 @samp{2002-03-30 23:45}.  These timestamps are shorter than
 @samp{full-iso} timestamps, and are usually good enough for everyday
 work.  This style is equivalent to @samp{+%Y-%m-%d %H:%M}.
 
 @item iso
 List ISO 8601 dates for non-recent timestamps (e.g.,
-@samp{2002-03-30@ }), and ISO 8601 month, day, hour, and
+@samp{2002-03-30@ }), and ISO 8601 like month, day, hour, and
 minute for recent timestamps (e.g., @samp{03-30 23:45}).  These
 timestamps are uglier than @samp{long-iso} timestamps, but they carry
 nearly the same information in a smaller space and their brevity helps
@@ -11491,13 +11491,13 @@ with @command{date}, @var{format}'s interpretation is affected by the
 @env{LC_TIME} locale category.
 
 @item full-iso
-List timestamps in full using ISO 8601 date, time, and time zone
-format with nanosecond precision, e.g., @samp{2002-03-30
+List timestamps in full using ISO 8601 like date, time, and time zone
+components with nanosecond precision, e.g., @samp{2002-03-30
 23:45:56.477817180 -0700}.  This style is equivalent to
 @samp{+%Y-%m-%d %H:%M:%S.%N %z}.
 
 @item long-iso
-List ISO 8601 date and time in minutes, e.g.,
+List ISO 8601 like date and time in minutes, e.g.,
 @samp{2002-03-30 23:45}.  These timestamps are shorter than
 @samp{full-iso} timestamps, and are usually good enough for everyday
 work.  This style is equivalent to @samp{+%Y-%m-%d %H:%M}.
@@ -15239,7 +15239,13 @@ Append the hours, minutes, seconds and nanoseconds.
 @end table
 
 If showing any time terms, then include the time zone using the format
-@samp{%z}.
+@samp{%:z}.
+@macro dateParseNote
+This format is always suitable as input
+for the @option{--date} (@option{-d}) and @option{--file}
+(@option{-f}) options, regardless of the current locale.
+@end macro
+@dateParseNote
 
 @item -r @var{file}
 @itemx --reference=@var{file}
@@ -15274,10 +15280,8 @@ Display the date using a format specified by
 @uref{ftp://ftp.rfc-editor.org/in-notes/rfc3339.txt, Internet
 RFC 3339}.  This is a subset of the ISO 8601
 format, except that it also permits applications to use a space rather
-than a @samp{T} to separate dates from times.  Unlike the other
-standard formats, RFC 3339 format is always suitable as
-input for the @option{--date} (@option{-d}) and @option{--file}
-(@option{-f}) options, regardless of the current locale.
+than a @samp{T} to separate dates from times.
+@dateParseNote
 
 The argument @var{timespec} specifies how much of the time to include.
 It can be one of the following:
index 732204ee805e817c8ff3d389e51c788f6baa6e71..50e71d74ac1d8efa1f2e6a5460ec51ab5aba051f 100644 (file)
@@ -382,10 +382,10 @@ main (int argc, char **argv)
             static char const iso_8601_format[][32] =
               {
                 "%Y-%m-%d",
-                "%Y-%m-%dT%H:%M:%S%z",
-                "%Y-%m-%dT%H:%M:%S,%N%z",
-                "%Y-%m-%dT%H%z",
-                "%Y-%m-%dT%H:%M%z"
+                "%Y-%m-%dT%H:%M:%S%:z",
+                "%Y-%m-%dT%H:%M:%S,%N%:z",
+                "%Y-%m-%dT%H%:z",
+                "%Y-%m-%dT%H:%M%:z"
               };
             enum Time_spec i =
               (optarg
index 6a7c6f88b23e8bcf2bdb15ad9011fdbbcb395187..ad07fa485adcc33ae2dfebad359a14f96fefb070 100755 (executable)
@@ -203,17 +203,17 @@ my @Tests =
      ['moname-d-y-r', '--rfc-3339=date -d May-23-2003', {OUT=>"2003-05-23"}],
 
      ['epoch', '--iso=sec -d @31536000',
-      {OUT=>"1971-01-01T00:00:00+0000"}],
+      {OUT=>"1971-01-01T00:00:00+00:00"}],
      ['epoch-r', '--rfc-3339=sec -d @31536000',
       {OUT=>"1971-01-01 00:00:00+00:00"}],
 
      ['ns-10', '--iso=ns', '-d "1969-12-31 13:00:00.00000001-1100"',
-      {OUT=>"1970-01-01T00:00:00,000000010+0000"}],
+      {OUT=>"1970-01-01T00:00:00,000000010+00:00"}],
      ['ns-10-r', '--rfc-3339=ns', '-d "1969-12-31 13:00:00.00000001-1100"',
       {OUT=>"1970-01-01 00:00:00.000000010+00:00"}],
 
      ['ns-max32', '--iso=ns', '-d "2038-01-19 03:14:07.999999999"',
-      {OUT=>"2038-01-19T03:14:07,999999999+0000"}],
+      {OUT=>"2038-01-19T03:14:07,999999999+00:00"}],
      ['ns-max32-r', '--rfc-3339=ns', '-d "2038-01-19 03:14:07.999999999"',
       {OUT=>"2038-01-19 03:14:07.999999999+00:00"}],
 
@@ -235,7 +235,7 @@ my @Tests =
      ['ns-relative',
       '--iso=ns',
       "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'",
-      {OUT=>"2000-06-15T09:43:58,111111021+0000"}],
+      {OUT=>"2000-06-15T09:43:58,111111021+00:00"}],
      ['ns-relativer', '--rfc-3339=ns',
       "-d'1970-01-01 00:00:00.1234567 UTC +961062237.987654321 sec'",
       {OUT=>"2000-06-15 09:43:58.111111021+00:00"}],