0.1.1 • Published 11 years ago
random-date v0.1.1
random-date
pick up a random date to use. simple.
install
$ npm i random-dateusage
var randomDate = require('random-date');
var date = randomDate('1d');
// 1410559806731
// equals to Sat Sep 13 2014 06:10:06 GMT+0800 (CST)
// timestamp for now: Fri Sep 12 2014 17:23:54 GMT+0800 (CST)api
randomDate(str, [ref])
the str can be like these:
'1d' // yestday, today, tommorrow
'+1d' // today, tommorrow
'-1d' // yestday, today
'10' // 10ms ago to 10ms after
'+10' // now to 10ms afteractually, the str has two partions.
[direction] region
which, the direction is optional, and when it is +, means the random range is started from now,
if it is -, on the contrary, the random range is ended at now.
At last, when it is omited, the random range is started from region before now, and end at region after now.
the region is a string specify a time range, it can be just a number, means how many ms, and it also support every unit that ms supported.
ref, the reference time for the range, if no ref arg, the range is calculate with current time, if it has ref arg,
the range is calculate with the ref.
eg:
var randomDate = require('random-date');
var date = randomDate('1d', '2014-01-01');
// 1388571166958
// equals to Wed Jan 01 2014 18:12:46 GMT+0800 (CST)