From 40523da708160e95ad45cefe19aa2bb668903c46 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 25 Jun 2009 23:59:23 +0000 Subject: [PATCH] Implement %z for strptime. PR: kern/63064 Submitted by: Stefan `Sec` Zehl (with some small changes) MFC after: 1 month --- lib/libc/stdtime/strptime.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index ddf6b57e38fc..c7de35c0d686 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -514,6 +514,34 @@ label: } } break; + + case 'z': + { + int sign = 1; + + if (*buf != '+') { + if (*buf == '-') + sign = -1; + else + return 0; + } + + buf++; + i = 0; + for (len = 4; len > 0; len--) { + if (isdigit((int)*buf)) { + i *= 10; + i += *buf - '0'; + buf++; + } else + return 0; + } + + tm->tm_hour -= sign * (i / 100); + tm->tm_min -= sign * (i % 100); + *GMTp = 1; + } + break; } } return (char *)buf;