
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
amazon-date-parser
Advanced tools
Given an AMAZON.DATE returns an object with the relative start and end date.
npm install amazon-date-parser
var AmazonDateParser = require('amazon-date-parser');
var date = new AmazonDateParser('2017-01-31');
/*
returns:
{
startDate: Tue Jan 31 2017 00:00:00 GMT+0000 (GMT),
endDate: Tue Jan 31 2017 23:59:59 GMT+0000 (GMT)
}
*/
It throws an error when the date is not valid or not supported.
var AmazonDateParser = require('amazon-date-parser');
try {
var date = new AmazonDateParser('dummy');
}catch(e) {
console.log(e.message);
}
// Error: Invalid constructor parameter or parameter not supported.
2017-11-242017-W482017-W48-WE2017-112018-Q22017-SP, 2017-WI, 2017-FA, 2017-SU (see below)2018201XThe constructor receives the following optional parameters only valid for season's calculations.
{
hemisphere: 'N', //`N` for North, `S` for the South hemisphere (default is `N`)
seasons: { // see Custom seasons for more info about this parameter
// ...
'SU': { // summer
startDate: [5, 1], // 1st of June
endDate: [8, 0] // 31st of August
}
// ...
}
}
The seasons parameters overrides all the others. For instance, if you provide seasons and hemisphere the latter will be ignored.
The north hemisphere seasons are by default defined as follow:
For the south hemisphere you should construct the Amazon date parser as follow:
var date = new AmazonDateParser({hemisphere: 'S'});
and you can get:
You can pass your own seasons representation using the following configurations:
var options = {
seasons: {
'SP': {
startDate: [2, 1], // 1st of March
endDate: [3, 0] // end of March
},
'SU': {
startDate: [5, 1], // 1st of June
endDate: [8, 0] // end of August
},
'FA': {
startDate: [8, 1], // 1st of September
endDate: [11, 0] // end of November
},
'WI': {
startDate: [11, 1], // 1st of December
endDate: [2, 0] // end of February (28th or 29th)
}
}
var AmazonDateParser = require('amazon-date-parser');
var date = new AmazonDateParser('2018-SP', options);
/*
returns something like:
{
startDate: Thu Mar 01 2018 00:00:00 GMT+0000 (GMT),
endDate: Sat Mar 31 2018 23:59:59 GMT+0000 (GMT)
}
*/
The MIT License (MIT). Please see License File for more information.
FAQs
Parse AMAZON.DATE to a date range
The npm package amazon-date-parser receives a total of 397 weekly downloads. As such, amazon-date-parser popularity was classified as not popular.
We found that amazon-date-parser 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
/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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.