From patchwork Tue Jan 27 15:05:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Bernat X-Patchwork-Id: 433539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2A2871401EF for ; Wed, 28 Jan 2015 02:06:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=Fs755ecb8boxYhdcoHzWCueotymwfGmkcHu9ypL5UwcZaEhFvWEBR pgNpjJRETuYuWCUk+YJrzLt0Icyx2mURmYypTXlTFNQyNfj6lOVMNmi/Joc+OAGB iWNkzOdU/VSrtOgOwc+d5upUnIUZu6AQbDlCxjPqTMpy0bzgTbzM9U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=Nh6ceXjBSzSsS2Epy7U+EUFX07w=; b=I66OJHbax2GFZnAbwB6frlbr3/wi oic92dnj4aR5lXzzJ6rErRqDJlv4W6L+wUD4wO6aXXCFCYGchrln8W03ycT8J1uS ok0R1wNJIhOnO0LmMHyLdIa+U3225krPobdsaQxGq638/VU2PXs3nBrAT6tCr+rs iR6Mf3hzkJHkUk8= Received: (qmail 1899 invoked by alias); 27 Jan 2015 15:05:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1025 invoked by uid 89); 27 Jan 2015 15:05:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.0 required=5.0 tests=SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: bart.luffy.cx From: Vincent Bernat To: libc-alpha@sourceware.org Cc: Vincent Bernat Subject: [PATCH] time: in strptime(), make %z accept Z as a time zone Date: Tue, 27 Jan 2015 16:05:40 +0100 Message-Id: <1422371140-27932-1-git-send-email-Vincent.Bernat@exoscale.ch> From: Vincent Bernat 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 + + [BZ #17886] + * time/strptime_l.c: Make %z accept Z as a valid time zone. + 2015-01-27 Andreas Krebbel * 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 },