Calculate leap years for a period of years in Apperyio app.


Sometimes you need to know how much leap years you have for a certain period of years.


Add small function listed bellow to you momentjs(v2.14.1) library.
This is a simplest solution, which can and will be optimized:

To add this function to momentjs just find isLeapYear function like I did, so it will be together.
function numLeapYears

Don’t forget to add this function to momentjs proto or it will be undefined.

adding function to momentjs proto

Now we can use it. My result you can see on a screenshot below.
testing numLeapYears function

Leave a Reply

Your email address will not be published. Required fields are marked *