From aae6d9720e77f5f371a865e65eac9cd26626008d Mon Sep 17 00:00:00 2001 From: "Shane A. Stillwell" Date: Wed, 21 May 2014 21:19:04 -0500 Subject: Ensure Date.future returns a date in the future. --- lib/date.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/date.js b/lib/date.js index 795e674e..1b93f4e6 100644 --- a/lib/date.js +++ b/lib/date.js @@ -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 * 3600 * 1000 + 1000; // some time from now to N years later, in milliseconds date.setTime(future) return date.toJSON(); -- cgit v1.2.3 From 8b894a08c89ae803bbd3c2a9721ff859fae13ea5 Mon Sep 17 00:00:00 2001 From: Ed Shadi Date: Mon, 16 Jun 2014 11:33:15 -0700 Subject: added hours in date.recent. Currently the code returns date in past minutes. random days could return 0 so modified the test to reflect <= current date. --- lib/date.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/date.js b/lib/date.js index 795e674e..23e0dc58 100644 --- a/lib/date.js +++ b/lib/date.js @@ -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 * 60 * 60 * 1000; // some time from now to N days ago, in milliseconds date.setTime(future) return date.toJSON(); -- cgit v1.2.3 From 9391c00943503f2f2092749fb67b4e1dbd38f827 Mon Sep 17 00:00:00 2001 From: Ed Shadi Date: Mon, 16 Jun 2014 13:22:28 -0700 Subject: random number now accepts a range array [min, max]. --- lib/random.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/random.js b/lib/random.js index fcd451d7..63347278 100644 --- a/lib/random.js +++ b/lib/random.js @@ -1,8 +1,12 @@ var definitions = require('./definitions'); - var random = { - // returns a single random number based on a range + // returns a single random number based on a max number or range number: function (range) { + if(Array.isArray(range)) { + var min = range[0]; + var max = range[1]; + return Math.floor((Math.random() * max) + min); + } return Math.floor(Math.random() * range); }, -- cgit v1.2.3