posix - Testing for leap seconds for a given time_t in Linux -
is there simple way of determining how many (if any) leap seconds applied given implementation of:
time_t unix_seconds = mktime(&my_tm); for example, there field populated in my_tm?
otherwise, suppose option test known time_t values given times bordering leap second transitions, nice if there more convenient.
you reduce problem finding out how many leap seconds there between 2 time_t times.
to find that, calculate tm struct both times ta , tb, , calculate number of seconds have passed since last hour doing atmstruct->tm_min*60 + atmstruct->tm_sec. store seca , secb.
then calculate difftime of ta , tb. (diff + secb - seca) % 3600 should give number of leap seconds, long fewer 3600 leapseconds between ta , tb. basically, if there leap second inserted difftime should 1 larger difference between seca , secb.
Comments
Post a Comment