[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: os.time() and the last second of 1969
- From: Dirk Jagdmann <doj@...>
- Date: Sat, 12 Feb 2022 14:07:55 -0800
these are some good suggestions, but they don't seem to work. I've
tested on some systems:
OsX doesn't set errno, and will also calculate values for tm_wday and
tm_ydat.
An old 32bit Linux doesn't set errno, and will also calculate values for
tm_wday and tm_ydat.
A modern 64bit Linux doesn't set errno, and will also calculate values
for tm_wday and tm_ydat.
It seems as if all these implementations are not checking the values of
the struct tm member variables for a valid range, but simply take these
integer values and use them in their formula to calculate the timestamp
value.
I briefly looked into the BSD and Linux implementations of these functions:
https://github.com/lattera/freebsd/blob/master/contrib/ntp/libntp/mktime.c
https://github.com/lattera/glibc/blob/master/time/mktime.c
and there is a lot going on. But as said these functions are trying to
"make up" for values in the struct tm outside the typical range for
seconds, minutes, months, etc. So it seems that checking for errno or
unchanged values of tm_yday is not working.
--
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org