1.0.1 • Published 5 years ago

@strong-roots-capital/years-between v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

years-between Build status npm version codecov

List years between two dates, inclusive

Install

npm install @strong-roots-capital/years-between

Use

import yearsBetween from '@strong-roots-capital/years-between'
import moment from 'moment'

console.log(
    yearsBetween(
        moment.utc().startOf('year').toDate(),
        moment.utc().startOf('year').toDate()
    )
)
//=>[ 2019 ]

console.log(
    yearsBetween(
        moment.utc().startOf('year').toDate(),
        moment.utc().startOf('year').add(1, 'years').toDate()
    )
)
//=>[ 2019, 2020 ]

console.log(
    // Note: supports function currying
    yearsBetween(moment.utc().startOf('year').toDate())
                (moment.utc().startOf('year').add(2, 'years').toDate())
)
//=>[ 2019, 2020, 2021 ]
1.0.1

5 years ago

1.0.0

5 years ago