diff options
| author | Gordon Tetlow <gordon@FreeBSD.org> | 2025-10-15 22:24:06 +0000 |
|---|---|---|
| committer | Gordon Tetlow <gordon@FreeBSD.org> | 2025-10-15 22:24:07 +0000 |
| commit | 79e57ea662d92ffcbe7d65854a284aefac6a332d (patch) | |
| tree | 4ac44367c03e3164fd47b375c164fa522bc49046 | |
| parent | 4548b9f3a8167a340a5086ed51a76d932c9ab3cc (diff) | |
libc: Add "Z" as TZ designator for strptime.
ISO 8601 allows use of "Z" as the time zone designator. Update the
strptime parser to allow this usage.
While we are at it, update the manpage to reflect that both UTC and Z
are now valid options.
Reviewed by: des
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53083
| -rw-r--r-- | lib/libc/stdtime/strptime.3 | 2 | ||||
| -rw-r--r-- | lib/libc/stdtime/strptime.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdtime/strptime.3 b/lib/libc/stdtime/strptime.3 index 7df73d2d080a..9456fa757b85 100644 --- a/lib/libc/stdtime/strptime.3 +++ b/lib/libc/stdtime/strptime.3 @@ -171,7 +171,7 @@ is taken as noon. The .Fa %Z format specifier only accepts time zone abbreviations of the local time zone, -or the value "GMT". +and the values "GMT", "UTC", or "Z". This limitation is because of ambiguity due to of the over loading of time zone abbreviations. One such example is diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 5f1293c7a267..375e49146639 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -546,7 +546,8 @@ label: zonestr[cp - buf] = '\0'; tzset(); if (0 == strcmp(zonestr, "GMT") || - 0 == strcmp(zonestr, "UTC")) { + 0 == strcmp(zonestr, "UTC") || + 0 == strcmp(zonestr, "Z")) { *GMTp = 1; } else if (0 == strcmp(zonestr, tzname[0])) { tm->tm_isdst = 0; |
