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

1.0.0 • Public • Published

dates-between Build status npm version codecov

Generator returning all dates from start date to end date, inclusive

Install

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

Use

import { datesBetween, allDatesBetween } from '@strong-roots-capital/dates-between'
import moment from 'moment'

const newYears = moment.utc().startOf('year').toDate()
const today = moment.utc().startOf('year').add(1, 'week').toDate()

for (const date of datesBetween(newYears, today)) {
    console.log(date)
}
//=>2019-01-01T00:00:00.000Z
//=>2019-01-02T00:00:00.000Z
//=>2019-01-03T00:00:00.000Z
//=>2019-01-04T00:00:00.000Z
//=>2019-01-05T00:00:00.000Z
//=>2019-01-06T00:00:00.000Z
//=>2019-01-07T00:00:00.000Z
//=>2019-01-08T00:00:00.000Z

const allDates = allDatesBetween(newYears, today)
console.log(allDates)
//=>[ 2019-01-01T00:00:00.000Z,
//    2019-01-02T00:00:00.000Z,
//    2019-01-03T00:00:00.000Z,
//    2019-01-04T00:00:00.000Z,
//    2019-01-05T00:00:00.000Z,
//    2019-01-06T00:00:00.000Z,
//    2019-01-07T00:00:00.000Z,
//    2019-01-08T00:00:00.000Z ]

Readme

Keywords

Package Sidebar

Install

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

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

10.8 kB

Total Files

6

Last publish

Collaborators

  • amchelle
  • hamroctopus