aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpmalouin <[email protected]>2014-02-22 16:27:51 -0500
committerpmalouin <[email protected]>2014-02-22 16:27:51 -0500
commitbf733f9dc1e8c6e6a698b082c17a2840dd471cb9 (patch)
tree1d787922c51c2a1c0e847f63e4d12c12adf5e081
parent0c49ffcfd98ef2dc7ef56e63b90cdcfc7a624081 (diff)
downloadfaker-bf733f9dc1e8c6e6a698b082c17a2840dd471cb9.tar.xz
faker-bf733f9dc1e8c6e6a698b082c17a2840dd471cb9.zip
Fixed random date functions that did not distribute results evenly over the requested period.
-rw-r--r--lib/date.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/date.js b/lib/date.js
index 795e674e..6b1043b6 100644
--- a/lib/date.js
+++ b/lib/date.js
@@ -6,7 +6,7 @@ var date = {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var past = date.getTime();
- past -= Faker.random.number(years) * 365 * 3600 * 1000; // some time from now to N years ago, in milliseconds
+ past -= Faker.random.number(years * 365 * 24 * 3600 * 1000); // some time from now to N years ago, in milliseconds
date.setTime(past)
return date.toJSON();
@@ -15,7 +15,7 @@ var date = {
future: function (years, refDate) {
var date = (refDate) ? new Date(Date.parse(refDate)) : new Date();
var future = date.getTime();
- future += Faker.random.number(years) * 365 * 3600 * 1000; // some time from now to N years later, in milliseconds
+ future += Faker.random.number(years * 365 * 24 * 3600 * 1000); // some time from now to N years later, in milliseconds
date.setTime(future)
return date.toJSON();
@@ -33,7 +33,7 @@ var date = {
recent: function (days) {
var date = new Date();
var future = date.getTime();
- future -= Faker.random.number(days) * 3600 * 1000; // some time from now to N days ago, in milliseconds
+ future -= Faker.random.number(days * 24 * 3600 * 1000); // some time from now to N days ago, in milliseconds
date.setTime(future)
return date.toJSON();