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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With