]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
time: in strptime(), make %z accept Z as a time zone [BZ #17886]
authorVincent Bernat <Vincent.Bernat@exoscale.ch>
Thu, 17 Sep 2015 07:55:04 +0000 (09:55 +0200)
committerMike Frysinger <vapier@gentoo.org>
Fri, 18 Sep 2015 05:15:45 +0000 (01:15 -0400)
In ISO 8601, the timezone can be 'Z' instead of using
digits. 2014-08-17T12:33:12+0000 is often expressed as
2014-08-17T12:33:12Z.

ChangeLog
NEWS
time/strptime_l.c
time/tst-strptime2.c

index 5fe57ba2e09604bb168a3f76244e72f8e88cc40f..97f05486cf058a07e92d28bd5275735ead177757 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-18  Vincent Bernat  <vincent@bernat.im>
+
+       [BZ #17886]
+       * time/strptime_l.c (__strptime_internal): Make %z accept Z as a
+       valid time zone.
+
 2015-09-17  Mike Frysinger  <vapier@gentoo.org>
 
        * sysdeps/unix/sysv/linux/alpha/Makefile (CFLAGS-fdatasync.c): Delete.
diff --git a/NEWS b/NEWS
index e5a4629858491591cd5dba84303cca604df76dc5..d304f8ce8624f02533a8b1dfb408809e7a4f6175 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,11 +11,11 @@ Version 2.23
 
   2542, 2543, 2558, 2898, 4404, 6803, 14341, 14912, 15384, 15786, 15918,
   16141, 16296, 16415, 16517, 16519, 16520, 16521, 16734, 16973, 16985,
-  17118, 17243, 17244, 17787, 17905, 18084, 18086, 18240, 18265, 18370,
-  18421, 18480, 18525, 18595, 18610, 18618, 18647, 18661, 18674, 18675,
-  18681, 18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796, 18820,
-  18823, 18824, 18857, 18863, 18870, 18872, 18873, 18875, 18887, 18921,
-  18951, 18952, 18961, 18966, 18967, 18970, 18977
+  17118, 17243, 17244, 17787, 17886, 17905, 18084, 18086, 18240, 18265,
+  18370, 18421, 18480, 18525, 18595, 18610, 18618, 18647, 18661, 18674,
+  18675, 18681, 18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796,
+  18820, 18823, 18824, 18857, 18863, 18870, 18872, 18873, 18875, 18887,
+  18921, 18951, 18952, 18961, 18966, 18967, 18970, 18977.
 
 * The obsolete header <regexp.h> has been removed.  Programs that require
   this header must be updated to use <regex.h> instead.
index 4203ad81a0f3b36c6d5feafac9eb42de49b472ee..989edd6144e686a3978817917303681ecfd8cc2d 100644 (file)
@@ -749,13 +749,19 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
            rp++;
          break;
        case 'z':
-         /* We recognize two formats: if two digits are given, these
+         /* We recognize three formats: if two digits are given, these
             specify hours.  If fours digits are used, minutes are
-            also specified.  */
+            also specified.  'Z' is equivalent to +0000.  */
          {
            val = 0;
            while (ISSPACE (*rp))
              ++rp;
+           if (*rp == 'Z')
+             {
+               ++rp;
+               tm->tm_gmtoff = 0;
+               break;
+             }
            if (*rp != '+' && *rp != '-')
              return NULL;
            bool neg = *rp++ == '-';
index 5b06a63ba4c3c0212438bde9d81c0b5e42337e1f..3d906dec74e79e9a67aa952b81579e582ac08038 100644 (file)
@@ -31,7 +31,8 @@ static bool verbose;
      whitespace matching strptime " " format specifier, and
      timezone string matching strptime "%z" format specifier.
 
-   Note that a valid timezone string contains the following fields:
+   Note that a valid timezone string is either "Z" or contains the
+   following fields:
      Sign field consisting of a '+' or '-' sign,
      Hours field in two decimal digits, and
      optional Minutes field in two decimal digits.
@@ -155,6 +156,13 @@ do_test (void)
   expect = LONG_MAX;
   result |= compare (buf, expect, nresult);
 
+  /* Create and test input string with "Z" input (valid format).
+     Expect tm_gmtoff of 0.  */
+
+  sprintf (buf, "%s Z", dummy_string);
+  expect = 0;
+  result |= compare (buf, expect, nresult);
+
   /* Create and test input strings with sign and digits:
      0 digits (invalid format),
      1 digit (invalid format),