[tz] strftime %s

Guy Harris gharris at sonic.net
Mon Jan 15 00:17:10 UTC 2024


On Jan 14, 2024, at 2:46 PM, Robert Elz via tz <tz at iana.org> wrote:

> Eg: in C, a time_t is *not* a count of seconds since some epoch, and
> simply printing a time_t value and expecting that to be seconds since
> the epoch, in a portable C application is incorrect.  POSIX specifies
> it as an integer count of seconds since 1970-01-01T00:00:00Z (at exactly
> 86400 seconds per day, every day, always).   C does not.   A C time_t
> might be a count of milliseconds, of microseconds, or 2-seconds, or
> BCD encoded, or almost anything (though I think it is now required
> to be an integer type - I believe it was once allowed to be a float).

According to ISO/IEC 9899:2018, time_t is required to be a "real type", which means either an integer type *or* a real floating-point type.  (I think some formalisms in which time is a complex number have been used, but C, at least, does not allow time_t to be a complex floating-point type, and there are no complex integer types.)

So, no, at least as of the aforementioned standard, which Wikipedia informs me is "C17", the "2018" in the full name notwithstanding, C does not require time_t to be an integer type - it still may be floating-point.


More information about the tz mailing list