random-day

1.0.1 • Public • Published

random-day

Generate a random day.

MIT License

build:? coverage:?

Install

$ npm install --save random-day 

Usage

var randomDay = require('random-day');
  
// API
// - randomDay([options]);
  
// options
// - year
// - month
// - min
// - max

By default, returns a day in a random month, from 1 to 31.

randomDay();
// => 23

Optionally specify month:

randomDay({ month: 1 }); // 1~31
// => 12

Optionally specify year when month is 2 to figure out leap years:

randomDay({ year: 2016 month: 2 }); // 1~29
// => 18

Optionally specify min, max, or both to limit the range.

randomDay({ min: 10 });
// => 11
 
randomDay({ max: 10 });
// => 7
 
randomDay({ min: 3, max: 9 });
// => 6

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

Package Sidebar

Install

npm i random-day

Weekly Downloads

1,516

Version

1.0.1

License

MIT

Last publish

Collaborators

  • bubkoo