days-in-a-row

3.0.0 • Public • Published

days-in-a-row

npm version Build Status

Return an array of dates (strings) based on a start date and a number.

Usage

const days = require('days-in-a-row');
const allTheDays = days(new Date('01/01/2017'), 45);
/* the result
[ '2017-01-01',
  '2017-01-02',
  ...
  '2017-02-13',
  '2017-02-14' ]
*/
 
// You can then map the results to javascript date object
const allTheDates = allTheDays((day) => new Date(day));
// Then something like daylight to format the day for display
var daylight = require('daylight');
const prettyDates = allTheDates.map((day) => daylight('l, F jS', day));
/*
[ 'Monday, Jan 1st',
  'Tuesday, Jan 2nd',
  ...
  'Monday, Feb 13th',
  'Tuesday, Feb 14th' ]
 */

Package Sidebar

Install

npm i days-in-a-row

Weekly Downloads

1,908

Version

3.0.0

License

Unlicense

Unpacked Size

3.01 kB

Total Files

6

Last publish

Collaborators

  • kev_nz