Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250606144131.GK1827@brightrain.aerifal.cx>
Date: Fri, 6 Jun 2025 10:41:32 -0400
From: Rich Felker <dalias@...ifal.cx>
To: Rafał Miłecki <zajec5@...il.com>
Cc: musl@...ts.openwall.com,
	Rafał Miłecki <rafal@...ecki.pl>
Subject: Re: [PATCH] strptime: support "Z" value for the %z field
 descriptor

On Fri, Jun 06, 2025 at 11:05:45AM +0200, Rafał Miłecki wrote:
> 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

At present we have another thread open reporting a bug from
implementing behavior that was reasonable but outside the standard for
strftime that looks like it's now nonconforming to the new standard.

If the above is to be adopted, I'd like to have some assurance that
it's not going to be contrary to future standards. Do other existing
implementations support this? Is there any effort to standardize it?

Rich

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.