diff options
| author | ST-DDT <[email protected]> | 2023-01-26 18:05:13 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-26 17:05:13 +0000 |
| commit | 04b4aacd16fd1e9129f906c6efd7b74ec6a75a1c (patch) | |
| tree | 4d7232756023a1b0424540a0636b8b371fbeab14 /src/modules | |
| parent | dcb318f4008e4600c98a794062e0d0bb061f88a9 (diff) | |
| download | faker-04b4aacd16fd1e9129f906c6efd7b74ec6a75a1c.tar.xz faker-04b4aacd16fd1e9129f906c6efd7b74ec6a75a1c.zip | |
chore: fix missing defaultRefDate calls (#1781)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/date/index.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts index 5c2c49eb..c99a7d19 100644 --- a/src/modules/date/index.ts +++ b/src/modules/date/index.ts @@ -11,8 +11,8 @@ import { deprecated } from '../../internal/deprecated'; * @param fallback The fallback date to use if the passed date is not valid. */ function toDate( - date?: string | Date | number, - fallback: () => Date = () => new Date() + date: string | Date | number | undefined, + fallback: () => Date ): Date { date = new Date(date); if (isNaN(date.valueOf())) { @@ -370,8 +370,8 @@ export class DateModule { const { from, to } = options; - const fromMs = toDate(from).getTime(); - const toMs = toDate(to).getTime(); + const fromMs = toDate(from, this.faker.defaultRefDate).getTime(); + const toMs = toDate(to, this.faker.defaultRefDate).getTime(); const dateOffset = this.faker.number.int(toMs - fromMs); return new Date(fromMs + dateOffset); @@ -948,7 +948,7 @@ export class DateModule { } = {} ): Date { const mode = options.mode === 'age' ? 'age' : 'year'; - const refDate = toDate(options.refDate); + const refDate = toDate(options.refDate, this.faker.defaultRefDate); const refYear = refDate.getUTCFullYear(); // If no min or max is specified, generate a random date between (now - 80) years and (now - 18) years respectively |
