[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: number of seconds since the epoch
Clearly you're looking for a count of seconds including
leap seconds, right? That's the magic 24 in your message.
That is you're not interested in the elastic seconds that
posix defines, for which there are always exactly 86400 in a day.
If so, then yes, the mechanisms for that do exist, the timezone
data that NetBSD uses can handle leap seconds, but "nice way" might
not be quite it.
You might need to recompile a timezone source file (the one that includes
your local timezone), uzing zic -L, to include leap second data
and put this version of the data for your zone somewhere convenient
(don't give it its normal name).
Then a program using time(0) and localtime() will make a struct tm
giving the local representation of the time now. You can fill in the
struct tm any other way you like if "now" isn't what you want.
Use your normal TZ setting for that part. Then change the TZ setting
to be your modified zone file, tzset(), and use mktime() to get a time_t.
In theory (I haven't tested that), that time_t should be a count of
seconds, including the leap seconds. Nice, no, not really, but
Main Index |
Thread Index |