@strong-roots-capital/years-between
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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 ]

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

7.54 kB

Total Files

6

Last publish

Collaborators

  • amchelle
  • hamroctopus