ancklo / ChaosMagPy

ChaosMagPy is a simple Python package for evaluating the CHAOS geomagnetic field model and other models of Earth's magnetic field.
Other
23 stars 3 forks source link

Leap years #1

Closed willjbrown88 closed 5 years ago

willjbrown88 commented 5 years ago

https://github.com/ancklo/ChaosMagPy/blob/25a9ee9d304ab35f809aa8087582530f94cfa99d/chaosmagpy/data_utils.py#L160

The current code will work since 2000 is likely the only case you have to deal with, but strictly (year % 4) == 0 doesn't hold for all cases, it's ((year % 400 == 0) or ((year % 4 == 0 ) and (year % 100 != 0))).

Up to you :)

If you don't mind importing another library then this would be easier:

import calendar
calendar.isleap(year)
ancklo commented 5 years ago

Yes, this is much better. I use the calendar package now.

Thank you for the tip!