MatthewYork / DateTools

Dates and times made easy in iOS
MIT License
7.22k stars 950 forks source link

Seconds in year constants #298

Open javisanesp opened 3 years ago

javisanesp commented 3 years ago

Hello there,

We noticed, thanks to my colleague @javiergm1983, that the constant value SECONDS_IN_YEAR is not correct. I do not know if you did it on purpose but following the standard convention, if it is considered a Gregorian year (365.2425 days), and a day are 86400 seconds, its value should be 52 seconds more.

SECONDS_IN_YEAR = (365.2425 days) * (86400 seconds/day) = 31556952 seconds

I took the liberty to add a few new constants that somebody might find useful:

SECONDS_IN_COMMON_YEAR = (365 days) * (86400 seconds/day) = 31536000 seconds
SECONDS_IN_JULIAN_YEAR = (365.25 days) * (86400 seconds/day) = 31557600 seconds
SECONDS_IN_LEAP_YEAR = (366 days) * (86400 seconds/day) = 31622400 seconds

Please let me know if you like and found this code useful.

Thank you.

Cheers!