
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
date-period
Advanced tools
Time period iterator.
A time period in this context is an iterable collection of Date objects, recurring at regular intervals, over a given period. Based on ISO 8601's duration and repeating interval format.
Mimics PHP's excellent DatePeriod class.
date-period requires babel-polyfill.
$ npm install date-period babel-polyfill --save
1.x API note: a period instance is now an ES6 iterable (iterate with
for ... of). In ES5 use-cases, you'll have to calltoArray, on which you can then use the regular array-methods.
let start = new Date('2014-01-01T00:00:00Z'),
duration = 'P1D',
end = new Date('2014-01-05T00:00:00Z'), // not included in result
period;
period = Period({start, duration, end});
// or, with the number of recurrences instead of an end date:
period = Period({start, duration, recurrence: 3});
// or, with a string formatted as an ISO 8601 repeating interval:
period = Period({iso: 'R3/2014-01-01T00:00:00Z/P1D'});
// in any case, period is an iterable object:
for (let date of period) {
/**
* will go over these dates:
* 2014-01-01T00:00:00Z
* 2014-01-02T00:00:00Z
* 2014-01-03T00:00:00Z
* 2014-01-04T00:00:00Z
*/
}
Note: the date and duration parameters can be objects which have, respectively,
toDateandtoStringmethods. This way moment objects are supported.
FAQs
Time period iterator
The npm package date-period receives a total of 130 weekly downloads. As such, date-period popularity was classified as not popular.
We found that date-period demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.