aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-04-17 17:11:00 +0200
committerGitHub <[email protected]>2024-04-17 15:11:00 +0000
commit462c80e09703010709a52531b85d0d9c0bbd3448 (patch)
tree1aafbb2e72fe51981185c787afb1b790d836069f /src/modules
parent0fe5af8b1849ce2b792baebdb52261f84a8242b4 (diff)
downloadfaker-462c80e09703010709a52531b85d0d9c0bbd3448.tar.xz
faker-462c80e09703010709a52531b85d0d9c0bbd3448.zip
fix(date): fix birthdate (#2829)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/date/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index f851c62e..10196d6e 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -523,7 +523,10 @@ export class SimpleDateModule extends SimpleModuleBase {
switch (mode) {
case 'age': {
- const from = new Date(refDate).setUTCFullYear(refYear - max - 1);
+ // Add one day to the `from` date to avoid generating the same date as the reference date.
+ const oneDay = 24 * 60 * 60 * 1000;
+ const from =
+ new Date(refDate).setUTCFullYear(refYear - max - 1) + oneDay;
const to = new Date(refDate).setUTCFullYear(refYear - min);
if (from > to) {