From the solidity docs on time units:

Take care if you perform calendar calculations using these units, because not every year equals 365 days and not even every day has 24 hours because of leap seconds. Due to the fact that leap seconds cannot be predicted, an exact calendar library has to be updated by an external oracle.

If say my contract calculates how much to withdraw based on a delta between two timestamps, should I worry about leap seconds?


What is the time unit for this contract, and the time scale? Is it payment per second, or payment per day? In the UTC time scale seconds are measured by hyperfine oscillations of cesium and days are measured by the rotating earth. In UTC (and only UTC) the duration of one day is not related to the duration of one second. Unix timestamps are, over the long run, subdivisions of days, not oscillations of cesium.

  • Payment per second. Here's the contract. Sep 25 '19 at 12:51
  • It looks important to define the desired time scale to finish answering the question. The word "second" by itself typically defaults to meaning "SI second" with time scale UTC or TAI, and because POSIX has chosen calendar days of 86400 seconds it cannot rigorously handle either of those time scales. If the desired time scale is related to legal calendar days then over the long run "second" means "mean solar second" and POSIX will handle the action as intended. When SI defined the second in terms of cesium they admitted that the older definitions of second still existed, just not as SI. Sep 26 '19 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.