Zanduino / DS3231M

Access the DS3231M I2C Realtime Clock
GNU General Public License v3.0
15 stars 7 forks source link

Calculate leap year #23

Closed capitainekurck closed 1 year ago

capitainekurck commented 1 year ago

Hello,

I m not a C guru but it seem that to find a leap year you divide the year by 4. you must also consider dividing by 100 and 400. There is an explanation here: https://learn.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year or here but it mid french mid english https://fr.wikihow.com/calculer-les-ann%C3%A9es-bissextiles regard

SV-Zanshin commented 1 year ago

That is correct, the original formula was incomplete, it has now been fixed to read

if (m > 2 && (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)))

SV-Zanshin commented 1 year ago

Change implemented in source

SV-Zanshin commented 1 year ago

Fixed