public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Vincent Bernat <Vincent.Bernat@exoscale.ch>
To: libc-alpha@sourceware.org
Cc: Vincent Bernat <vincent@bernat.im>
Subject: [PATCH] time: in strptime(), make %z accept Z as a time zone
Date: Tue, 27 Jan 2015 16:02:00 -0000	[thread overview]
Message-ID: <1422371140-27932-1-git-send-email-Vincent.Bernat@exoscale.ch> (raw)

From: Vincent Bernat <vincent@bernat.im>

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            | 5 +++++
 time/strptime_l.c    | 9 +++++++--
 time/tst-strptime2.c | 1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c6227b73c6c0..24c1a74c963d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-27  Vincent Bernat  <vincent@bernat.im>
+
+	[BZ #17886]
+	* time/strptime_l.c: Make %z accept Z as a valid time zone.
+
 2015-01-27  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
 	* iconv/loop.c: Suppress array out of bound warning caused by GCC
diff --git a/time/strptime_l.c b/time/strptime_l.c
index 5640ccecced0..78882ec39aed 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -749,13 +749,18 @@ __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++;
+                break;
+              }
 	    if (*rp != '+' && *rp != '-')
 	      return NULL;
 	    bool neg = *rp++ == '-';
diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index a08e6d7cb7de..c22967a93026 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -17,6 +17,7 @@ static const struct
     { "1113472456 -1030", -37800 },
     { "1113472456 +0030", 1800 },
     { "1113472456 -0030", -1800 },
+    { "1113472456  Z", 0 },
     { "1113472456 -1330", LONG_MAX },
     { "1113472456 +1330", LONG_MAX },
     { "1113472456 -1060", LONG_MAX },
-- 
2.1.4

         reply	other threads:[~2015-01-27 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 15:20 [PATCH] time: ensure failing strptime() tests are reported correctly Vincent Bernat
2015-01-27 16:02 ` Vincent Bernat [this message]
2015-03-06 10:11   ` [PATCH] time: in strptime(), make %z accept Z as a time zone Mike Frysinger
2015-01-27 16:03 ` [PATCH] time: in strptime(), make %z accept [+-]HH:MM time zones Vincent Bernat
2015-03-06 10:21   ` Mike Frysinger
2015-03-06 11:06     ` Vincent Bernat
2015-04-20 11:42     ` [BZ #17887][PATCH] " Vincent Bernat
2015-03-06 10:04 ` [PATCH] time: ensure failing strptime() tests are reported correctly Mike Frysinger
2015-03-06 11:02   ` Vincent Bernat
2015-03-06 11:07     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422371140-27932-1-git-send-email-Vincent.Bernat@exoscale.ch \
    --to=vincent.bernat@exoscale.ch \
    --cc=libc-alpha@sourceware.org \
    --cc=vincent@bernat.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).