Skip to content

Commit fa9d9de

Browse files
committed
Convert dob and registered to objects that include age
1 parent 7bdedc0 commit fa9d9de

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

api/1.2/api.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Fixed DOB and Registration dates to use ISO 8601 standard (yyyy-mm-ddThh:mm:ssZ)
3+
DOB and Registration dates are now objects that include age
34
Street numbers range from 1-9999
45
Add coordinates to location
56
Add timezone to location
@@ -68,7 +69,7 @@ var Generator = function(options) {
6869

6970
if (this.nat !== null) this.nat = uppercaseify(this.nat);
7071
this.nats = this.getNats(); // Returns array of nats
71-
this.constantTime = 1471295130;
72+
this.constantTime = 1529272048;
7273
this.version = version;
7374

7475
// Sanitize values
@@ -144,8 +145,17 @@ Generator.prototype.generate = function(cb) {
144145
});
145146

146147
let dob = range(-800000000000, this.constantTime*1000 - 86400000*365*21);
147-
this.include('dob', moment(dob).format('YYYY-MM-DDTHH:mm:ss\\Z'));
148-
this.include('registered', moment(range(1016688461000, this.constantTime*1000)).format('YYYY-MM-DDTHH:mm:ss\\Z'));
148+
let dobDate = moment(dob).format('YYYY-MM-DDTHH:mm:ss\\Z');
149+
this.include('dob', {
150+
date: dobDate,
151+
age: moment().diff(dobDate, 'years')
152+
});
153+
154+
let regDate = moment(range(1016688461000, this.constantTime*1000)).format('YYYY-MM-DDTHH:mm:ss\\Z');
155+
this.include('registered', {
156+
date: regDate,
157+
age: moment().diff(regDate, 'years')
158+
});
149159

150160
let id, genderText
151161
if (nat != 'LEGO') {

api/1.2/data/NO/inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = (inc, contents) => {
55
include(inc, 'phone', randomItem([2, 3, 5, 6, 7, 8]) + random(3, 7));
66
include(inc, 'cell', randomItem([4, 9]) + random(3, 7));
77
include(inc, 'id', () => {
8-
const dobDate = new Date(contents.dob),
8+
const dobDate = new Date(contents.dob.date),
99
dobISO = dobDate.toISOString(),
1010
birthDate = dobISO.substr(8, 2) + dobISO.substr(5, 2) + dobISO.substr(2, 2);
1111

routes/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var router = express.Router();
55
var Request = require('../models/Request');
66
var legRequest = require('request');
77

8-
var latestVersion = '1.1';
8+
var latestVersion = '1.2';
99

1010
router.get('/', (req, res, next) => {
1111
genUser(req, res, latestVersion);

0 commit comments

Comments
 (0)