aboutsummaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
Diffstat (limited to 'time')
-rw-r--r--time/strptime_l.c10
-rw-r--r--time/tst-strptime2.c10
2 files changed, 17 insertions, 3 deletions
diff --git a/time/strptime_l.c b/time/strptime_l.c
index 4203ad8..989edd6 100644
--- a/time/strptime_l.c
+++ b/time/strptime_l.c
@@ -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++ == '-';
diff --git a/time/tst-strptime2.c b/time/tst-strptime2.c
index 5b06a63..3d906de 100644
--- a/time/tst-strptime2.c
+++ b/time/tst-strptime2.c
@@ -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),