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:
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: