Skip to content

meltenc/week-identifier

Repository files navigation

npm mit license build status coverage status deps status

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

Get unique and sequential current week identifier for given valid Date string format

  • [date] {String} every valid Date-ish string format
  • return {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

Get monday date of the given week identifier or January 5, 1970 00:00:00 if weekIdentifier is <= 1.

  • [number] {String} every valid number > 0
  • return {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 MIT license

Copyright (c) 2016 [Clément Billiot], contributors.
Released under the MIT license.


About

Get unique and sequential week identifier of current date or given valid `Date` string format or Date object.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published