aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarak <[email protected]>2014-09-10 01:27:45 +0200
committerMarak <[email protected]>2014-09-10 01:27:45 +0200
commit198032b5d37a4882fc7d19d273475bb087685f2e (patch)
tree9f79457422a291d587d93eb1273d277655338e64 /lib
parentf4c05f8fbb9802e1ff0859fa5fdc19d0e6b70239 (diff)
downloadfaker-198032b5d37a4882fc7d19d273475bb087685f2e.tar.xz
faker-198032b5d37a4882fc7d19d273475bb087685f2e.zip
[fix] Do not serialize Dates from Date.random APIs. Dates are now returned as Date objects. #93
Diffstat (limited to 'lib')
-rw-r--r--lib/date.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/date.js b/lib/date.js
index c58a9af5..7b85143d 100644
--- a/lib/date.js
+++ b/lib/date.js
@@ -9,7 +9,7 @@ var date = {
past -= faker.random.number(years) * 365 * 3600 * 1000; // some time from now to N years ago, in milliseconds
date.setTime(past);
- return date.toJSON();
+ return date;
},
future: function (years, refDate) {
@@ -18,16 +18,16 @@ var date = {
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();
+ return date;
},
- between: function(from, to) {
+ between: function (from, to) {
var fromMilli = Date.parse(from);
var dateOffset = faker.random.number(Date.parse(to) - fromMilli);
var newDate = new Date(fromMilli + dateOffset);
- return newDate.toJSON();
+ return newDate;
},
recent: function (days) {
@@ -36,7 +36,7 @@ var date = {
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();
+ return date;
}
};
module.exports = date;