![]() |
|
Message-ID: <20250606090545.19298-1-zajec5@gmail.com> Date: Fri, 6 Jun 2025 11:05:45 +0200 From: Rafał Miłecki <zajec5@...il.com> To: musl@...ts.openwall.com Cc: Rafał Miłecki <rafal@...ecki.pl>, Rich Felker <dalias@...ifal.cx> Subject: [PATCH] strptime: support "Z" value for the %z field descriptor From: Rafał Miłecki <rafal@...ecki.pl> Field descriptor %z was added and described as an output of Austin Group tracker issues 879 & 1727. It is documented as: "The offset from UTC in the ISO 8601:2004 standard format (<tt>+hhmm</tt> or <tt>-hhmm</tt>)." It seems a bit vague as ISO 8601:2004 allows more formats than those specified ones. One of allowed values is "Z" which represents UTC. For a reference: glibc supports "Z" since 2015, see: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=900f33e23eaa20c0587f5a191b632a606e7fba5d To make ISO 8601 dates parsing reliable in musl make it accept "Z" as well. Cc: Rich Felker <dalias@...ifal.cx> Signed-off-by: Rafał Miłecki <rafal@...ecki.pl> --- For a reference: musl gained %z support in the commit fced99e93dae ("strptime: implement conversion specifiers adopted for next POSIX issue") Relevant issues: https://www.austingroupbugs.net/view.php?id=879 https://www.austingroupbugs.net/view.php?id=1727 src/time/strptime.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/time/strptime.c b/src/time/strptime.c index b1147242..b373aa9c 100644 --- a/src/time/strptime.c +++ b/src/time/strptime.c @@ -197,6 +197,11 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri want_century = 0; goto numeric_digits; case 'z': + if (*s == 'Z') { + tm->__tm_gmtoff = 0; + s++; + break; + } if (*s == '+') neg = 0; else if (*s == '-') neg = 1; else return 0; -- 2.43.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.