From 3620080f9b58fdd7c04c36685013edcdca6b3185 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 5 Oct 2014 07:29:50 +0000 Subject: 1) For %Z format, understand "UTC" name too. 2) Return NULL if timegm() fails, because it means we can convert what we have in GMT to local time needed. --- lib/libc/stdtime/strptime.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 8576bdb..55c9960 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -552,7 +552,8 @@ label: strncpy(zonestr, buf, cp - buf); zonestr[cp - buf] = '\0'; tzset(); - if (0 == strcmp(zonestr, "GMT")) { + if (0 == strcmp(zonestr, "GMT") || + 0 == strcmp(zonestr, "UTC")) { *GMTp = 1; } else if (0 == strcmp(zonestr, tzname[0])) { tm->tm_isdst = 0; @@ -674,6 +675,9 @@ strptime_l(const char * __restrict buf, const char * __restrict fmt, ret = _strptime(buf, fmt, tm, &gmt, loc); if (ret && gmt) { time_t t = timegm(tm); + + if (t == -1) + return (NULL); localtime_r(&t, tm); } -- cgit v1.1