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 +- test/date.unit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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(); diff --git a/test/date.unit.js b/test/date.unit.js index 83b73ca9..39f96a79 100644 --- a/test/date.unit.js +++ b/test/date.unit.js @@ -46,7 +46,7 @@ describe("date.js", function () { var date = Faker.Date.recent(30); - assert.ok(Date.parse(date) < new Date()); + assert.ok(Date.parse(date) <= new Date()); }); }); -- cgit v1.2.3