Solidity has keywords like seconds
, minutes
, hours
, days
and weeks
that are used to specify units of time.
Why do they not have years
?
Solidity had the year
keyword in all versions prior to 0.5.0
. It was removed due to complications and confusions about leap years.
From the Time Units section of the docs:
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.