week-identifier
v1.0.2
Published
Get unique and sequential current week identifier for given valid `Date` string format or Date object.
Downloads
571
Maintainers
Readme
Get unique and sequential current week identifier for given valid
Date
string format or Date object. Week #1 is starting on January 05, 1970.
Install
npm i --save week-identifier
npm test
week-identifier --help
API
For more use-cases see the tests
weekIdentifier
Get unique and sequential current week identifier for given valid
Date
string format
[date]
{String} every valid Date-ish string formatreturn
{Number}
Example:
var weekIdentifier = require('week-identifier');
// august 12, 2016
weekIdentifier();
//=> 2432
weekIdentifier('January 05, 1970 00:00:00');
//=> 1
weekIdentifier('January 12, 1970 00:00:00');
//=> 2
weekIdentifier(new Date('August 12, 2016'));
//=> 2432
weekIdentifier('08/12/2016');
//=> 2432
weekIdentifier('August 12, 2016');
//=> 2432
weekIdentifier(new Date('August 19, 2016'));
//=> 2433
weekIdentifier.dateFromWeek
Get monday date of the given week identifier or January 5, 1970 00:00:00 if weekIdentifier is <= 1.
[number]
{String} every valid number > 0return
{Date}
Example:
var weekIdentifier = require('week-identifier');
weekIdentifier.dateFromWeek(2433);
//=> August 15, 2016 00:00:00
weekIdentifier.dateFromWeek(1);
//=> January 05, 1970 00:00:00
CLI
You can just run
week-identifier --help
for more information
License
Copyright (c) 2016 [Clément Billiot], contributors.
Released under the MIT
license.