Dealing with leap years

I would try using Dates (from the standard library docs here: Dates · The Julia Language)

For your example:

using Dates

dr = Date(2000,1,17):Day(1):Date(2020,1,17)
count(x -> monthday(x) == (2, 29), dr)

Also there’s:

isleapyear(2020)

This should address all of the complications of leap years (2020 is a leap year, 2100 is not, 2000 is)

6 Likes