lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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