FrozenHeart FrozenHeart - 1 year ago 73
C Question

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

According to the,

field from the
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.

Answer Source

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 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download