diff options
author | delphij <delphij@FreeBSD.org> | 2009-06-25 23:59:23 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2009-06-25 23:59:23 +0000 |
commit | 25f6ec08bf8732908a215205c7818d59535b51b9 (patch) | |
tree | ad8f5a7ef80583d20769a2c43b2e8f4c066489db /lib/libc | |
parent | 77b27ab14910efed8d47105b445b24b01dc616eb (diff) | |
download | FreeBSD-src-25f6ec08bf8732908a215205c7818d59535b51b9.zip FreeBSD-src-25f6ec08bf8732908a215205c7818d59535b51b9.tar.gz |
Implement %z for strptime.
PR: kern/63064
Submitted by: Stefan `Sec` Zehl <sec 42 org> (with some small changes)
MFC after: 1 month
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdtime/strptime.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index ddf6b57..c7de35c 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; |