"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
"Todd C. Miller" <millert@openbsd.org>
Subject:
Re: Regress failures: regress, histedit
To:
Stefan Sperling <stsp@stsp.name>
Cc:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sat, 28 Aug 2021 10:12:01 -0600

Download raw body.

Thread
On Sat, 28 Aug 2021 17:48:43 +0200, Stefan Sperling wrote:

> When writing commits we always store a UTC timestamp, as obtained
> from time(3), and a timezone offset of 0. Git will then show UTC
> timestamps for commits generated by us. I've just verified again
> that this behaviour does indeed already work as intended.
>
> For display purposes we need a function which converts a time_t value
> into a const char * date string without adjusting for anything,
> ignoring the value of the TZ env var and such.
> Which C library function would be the best one to use for this purpose?

gmtime_r() + either strftime() or asctime().

> Perhaps we should be setting TZ and calling tzset() from inside the
> program to force libc to use UTC? Being required to do this would seem
> wrong to me. But a brief look at the code of the gmtime_r() and related
> functions seems to suggest that we should be doing this?

I don't see why you would need to do that.  As long as you are using
gmtime_r() the local timezone should not be relevant.

I think the problem here is the use of localtime_r().

 - todd