Strftime(3c) Does Not Show The Leap Second As 23:59:60 (Doc ID 1444354.1)

Last updated on OCTOBER 25, 2016

Applies to:

Solaris Operating System - Version 10 3/05 to 11 11/11 [Release 10.0 to 11.0]
Information in this document applies to any platform.

Goal

According to the man page of strftime(3C)

Standard C Library Functions strftime(3C)
...
%S Seconds [00,60]; the range of values is [00,60]
rather than [00,59] to allow for the occasional
leap second.
...

When you set up the leap second on your own ntp server as described in :
Solaris[TM] leap second solution (Doc ID 1019692.1)

And then  wrote a C program for printing/validating leap second of the ntp server.
Output looks like:
ticks 1341100798   23:59:58    Sat Jun 30 23:59:58 2012 timestate 1
ticks 1341100798   23:59:58   Sat Jun 30 23:59:58 2012 timestate 1
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 1
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 1
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 1
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 3
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 3
ticks 1341100799   23:59:59   Sat Jun 30 23:59:59 2012 timestate 3
ticks 1341100800   00:00:00   Sun Jul 01 00:00:00 2012 timestate 4
ticks 1341100800   00:00:00   Sun Jul 01 00:00:00 2012 timestate 4
ticks 1341100801   00:00:01   Sun Jul 01 00:00:01 2012 timestate 4

Mainly the last column is of interest. It shows the clock state
as defined in /usr/include/sys/timex.h

/*
* Clock states (time_state)
*/
#define TIME_OK 0 /* no leap second warning */
#define TIME_INS 1 /* insert leap second warning */
#define TIME_DEL 2 /* delete leap second warning */
#define TIME_OOP 3 /* leap second in progress */
#define TIME_WAIT 4 /* leap second has occured */
#define TIME_ERROR 5 /* clock not synchronized */

The two times were formated as follows from localtime() :
strftime (buffer1, SIZE, "%H:%M:%S", loctime);
strftime (buffer2, SIZE, "%c", loctime);

We can see that the leap second is occurring correctly but :

Why 23:59:59 is printed during a leap second instead of 23:59:60 according to the man pages of strftime(3C) ?


Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms