I understand the NTP protocol, so keeping system time updated is not a problem.
Standard C library routines like localtime() take a number of UTC seconds elapsed since the start of the epoch (Jan 1, 1970). These times in seconds can be a filetime, system time, or some other time in the past or the future.
In order to translate the seconds into years, months, days, etc. correctly the routines have to know about leap seconds. Including the one coming up this Dec 31, there are 23 leap seconds since 1970.
How is this accomplished? -- knowing about newly hatched leap seconds?
BTW HPUX 11.00 C runtine does not do this correction.... VAX C did.
/* leapsecond.c */
#include <time.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
time_t when=strtoul(argv[1],(char **)0,10);
struct tm *tmptr=gmtime(&when);
printf("%s\n",asctime(tmptr));
return 0;
}
gives this result:
kcsdev:/home/jmcnama> leapsecond 0
Thu Jan 1 00:00:00 1970
kcsdev:/home/jmcnama> leapsecond `echo "365*2*86400"|bc`
Sat Jan 1 00:00:00 1972
kcsdev:/home/jmcnama> leapsecond `echo "365*3*86400"|bc`
Sun Dec 31 00:00:00 1972
kcsdev:/home/jmcnama> leapsecond `echo "(365*3*86400)+86400"|bc`
Mon Jan 1 00:00:00 1973
There were two leap seconds in 1972, the translation does not take leap seconds into account.