Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of 61 in tm_sec field from the tm structure

Tags:

c++

c

According to the cplusplus.com, tm_sec field from the tm structure accept values from 0 to 61 in C90 and values from 0 to 60 in C99 and later.

I know that 60 can be used to express leap second but what about the other one (I mean 61)? And why did they choose to remove it?

Yeah, I tagged it both C and C++ because it is related to both languages in this case.

like image 636
FrozenHeart Avatar asked Oct 05 '16 21:10

FrozenHeart


1 Answers

A range of 0 to 61 allows for up to 2 consecutive leap seconds on December 31st of a given year, probably mistakenly because in years that require 2 leap seconds, these are not added on the same day.

Newer versions of the C Standard correctly assume that at most one leap second will be inserted at a time on any given day.

As explained in detail in https://en.wikipedia.org/wiki/Leap_second leap seconds are inserted in December and/or June in order to avoid a drift longer than 0.9 second, hence the maximum value for tm_sec should be 60 instead of 61.

like image 191
chqrlie Avatar answered Nov 15 '22 18:11

chqrlie