Socket
Book a DemoInstallSign in
Socket

moment-array-dates

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-array-dates

A small utility function that returns an array of formatted date strings.

2.0.3
latest
Source
npmnpm
Version published
Weekly downloads
71
-13.41%
Maintainers
1
Weekly downloads
 
Created
Source

Moment Array Dates

A small utility function that returns an array of formatted date strings.

Build Status Coverage Status Code Climate npm

Installation

npm install --save moment-array-dates

Usage

Import package:

var dateArray = require('moment-array-dates');

Functions

.range(startDate, endDate, format, ascending)

Returns an array of formatted dates including the start and end dates. Format and the last boolean parameter is optional.

dateArray.range('09/01/2016', '09/05/2016', 'MMM DD', true)

Output: [ 'Sep 01', 'Sep 02', 'Sep 03', 'Sep 04', 'Sep 05' ]

.lastNDays(number of days, format, ascending)

Returns an array of formatted dates from the last n days excluding today. Format and the last boolean parameter is optional.

# today: October 25, 2016
dateArray.lastNDays(5, 'MMM DD', true)

Output: [ 'Oct 20', 'Oct 21', 'Oct 22', 'Oct 23', 'Oct 24' ]

.nextNDays(number of days, format, ascending)

Returns an array of formatted dates from the next n days excluding today. Format and the last boolean parameter is optional.

# today: October 25, 2016
dateArray.nextNDays(5, 'MMM DD', true)

Output: [ 'Oct 26', 'Oct 27', 'Oct 28', 'Oct 29', 'Oct 30' ]

Please refer to the Momentjs documentation for formatting options

Todos

  • Do method chaining / piping for advanced operations

License

MIT

Keywords

date

FAQs

Package last updated on 31 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.