aboutsummaryrefslogtreecommitdiff
path: root/time/strptime_l.c
diff options
context:
space:
mode:
authorVincent Bernat <Vincent.Bernat@exoscale.ch>2015-09-17 09:56:13 +0200
committerMike Frysinger <vapier@gentoo.org>2015-09-18 01:17:15 -0400
commite952e1dfeb2a603ebd74ac5478a1218061ba893b (patch)
treeb87b971b154f92becba520451b6d3749c2f5ef4f /time/strptime_l.c
parent900f33e23eaa20c0587f5a191b632a606e7fba5d (diff)
downloadglibc-e952e1dfeb2a603ebd74ac5478a1218061ba893b.tar
glibc-e952e1dfeb2a603ebd74ac5478a1218061ba893b.tar.gz
glibc-e952e1dfeb2a603ebd74ac5478a1218061ba893b.tar.bz2
glibc-e952e1dfeb2a603ebd74ac5478a1218061ba893b.zip
time: in strptime(), make %z accept [+-]HH:MM tz [BZ #17887]
In ISO 8601, +03:30 is a valid time zone. Currently, strptime() only parses it as a 2-digit time zone an believes this is +03:00. This change makes it accept a single colon.
Diffstat (limited to 'time/strptime_l.c')
-rw-r--r--time/strptime_l.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/time/strptime_l.c b/time/strptime_l.c
index 989edd6144..c3ce50fe10 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -749,9 +749,11 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
rp++;
break;
case 'z':
- /* We recognize three formats: if two digits are given, these
- specify hours. If fours digits are used, minutes are
- also specified. 'Z' is equivalent to +0000. */
+ /* We recognize four formats:
+ 1. Two digits specify hours.
+ 2. Four digits specify hours and minutes.
+ 3. Two digits, ':', and two digits specify hours and minutes.
+ 4. 'Z' is equivalent to +0000. */
{
val = 0;
while (ISSPACE (*rp))
@@ -770,6 +772,8 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
{
val = val * 10 + *rp++ - '0';
++n;
+ if (*rp == ':' && n == 2 && isdigit (*(rp + 1)))
+ ++rp;
}
if (n == 2)
val *= 100;