aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/stdtime
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2014-10-05 07:29:50 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2014-10-05 07:29:50 +0000
commit420bc6cee4a3a10dc44f54079e96b270dac5c8be (patch)
tree5776b59d1c36f5815db9841906cfc39194f22ca7 /lib/libc/stdtime
parent513798cc9ce57dcf2899af77dffe3103fb33722b (diff)
downloadsrc-420bc6cee4a3a10dc44f54079e96b270dac5c8be.tar.gz
src-420bc6cee4a3a10dc44f54079e96b270dac5c8be.zip
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.
Notes
Notes: svn path=/head/; revision=272562
Diffstat (limited to 'lib/libc/stdtime')
-rw-r--r--lib/libc/stdtime/strptime.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index 8576bdb3750a..55c9960ff2c9 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);
}