# Dealing with leap years

**URL:** <https://discourse.julialang.org/t/dealing-with-leap-years/53516>\
**Category:** General Usage\
**Created:** [January 18, 2021, 4:39am UTC](https://discourse.julialang.org/t/dealing-with-leap-years/53516 "2021-01-18T04:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [January 18, 2021, 4:39am UTC](https://discourse.julialang.org/t/dealing-with-leap-years/53516/1 "2021-01-18T04:39:30Z")

</div>

I am trying to find a package that deals with leap years. For example a function that returns the number of days that fall on 29 February for some period. (There are some complications: years such that `mod(year,100)==0` are normally not leap years, but years such `mod(year,400)==0`, as year 2000, are leap years)

---

<div class="post-metadata">

**Author:** ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)\
**Post date:** [January 18, 2021, 5:54am UTC](https://discourse.julialang.org/t/dealing-with-leap-years/53516/2 "2021-01-18T05:54:06Z")

</div>

I would try using Dates (from the standard library docs here: [Dates · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Dates/))

For your example:

> [@askvorts](#):
>
> a function that returns the number of days that fall on 29 February for some period

```julia
using Dates

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

```

Also there’s:

```julia
isleapyear(2020)

```

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