> Date: Sat, 05 Nov 2022 20:49:57 +0700
> From: Robert Elz <k...@munnari.oz.au>
> 
> That's a variation of strftime() where you can tell it which time zone
> you want to use, instead of local time, for the conversions, so if you
> were to do
> 
>       z = tzalloc("UTC");
>       t = gmtime(&some_time_t_variable);
>       strftime_z(z, buf, sizeof buf, "whatever .. including %s %z and %Z", t);
>       
> then you'd get %s/%z/%Z values as specified by the UTC timezone, instead
> of current local time.   (Don't forget to tzfree(z) somewhere - or just 
> exit()).
> 
> That is, we don't need a new API, we already have the new API, just none
> of the participants here seem to have bothered to notice it.

I'm not sure this is adequately specified either.  The man page just
says:

     The strftime_z() function is similar to strftime(), but it also takes a
     const timezone_t tz argument.

This could mean several things:

1. strftime_z interprets the struct tm relative to tz, and formats it
   in tz.

2. strftime_z interprets the struct tm in its internal time zone
   recorded by gmtime/localtime, converts it to tz, and formats it in
   tz.

3. strftime_z interprets the struct tm in $TZ, converts it to tz, and
   formats it in tz.

4. strftime_z interprets the struct tm in tz, converts it to $TZ, and
   formats it in $TZ.

I expect it's one of these (probably (1)) but it's not obvious which
one and it's also not obvious that the one it implements is most
sensible or meets the expectations of uwe@ and dholland@ that spawned
this thread (probably (2)).

And, there's another option which I think is what uwe@ and dholland@
wanted for strftime which is inconvenient to get with any of these
options for strftime_z:

5. strftime_XXX interprets the struct tm in its internal time zone
   recorded by gmtime/localtime, converts it to $TZ, and formats it in
   $TZ.

Reply via email to