* [musl] [PATCH] strptime: support "Z" value for the %z field descriptor
@ 2025-06-06 9:05 Rafał Miłecki
0 siblings, 0 replies; only message in thread
From: Rafał Miłecki @ 2025-06-06 9:05 UTC (permalink / raw)
To: musl; +Cc: Rafał Miłecki, Rich Felker
From: Rafał Miłecki <rafal@milecki.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@aerifal.cx>
Signed-off-by: Rafał Miłecki <rafal@milecki.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-06-06 9:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-06 9:05 [musl] [PATCH] strptime: support "Z" value for the %z field descriptor Rafał Miłecki
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).