Skip to content

Commit

Permalink
Merge pull request #75 from mrstebo/issues/timezone-issues
Browse files Browse the repository at this point in the history
Fixed issue with dates on the birthday function.
  • Loading branch information
mrstebo committed Apr 9, 2017
2 parents 64108bc + 7d04621 commit a695a7e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/faker/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export function backward(days=365) {
}

export function birthday(minAge=18, maxAge=65) {
const now = new Date();
const from = new Date(now.getYear() - maxAge, now.getMonth(), now.getDay());
const to = new Date(now.getYear() - minAge, now.getMonth(), now.getDay());
const from = new Date();
from.setFullYear(from.getFullYear() - maxAge);
const to = new Date();
to.setFullYear(to.getFullYear() - minAge);
const date = between(from, to);
return date;
}
Expand Down

0 comments on commit a695a7e

Please sign in to comment.