aboutsummaryrefslogtreecommitdiff
path: root/src/modules/date
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/date')
-rw-r--r--src/modules/date/index.ts19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index 53204a03..06890a5d 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -1,28 +1,11 @@
import type { Faker } from '../..';
import type { DateEntryDefinition } from '../../definitions';
import { FakerError } from '../../errors/faker-error';
+import { toDate } from '../../internal/date';
import { assertLocaleData } from '../../internal/locale-proxy';
import { SimpleModuleBase } from '../../internal/module-base';
/**
- * Converts a date passed as a `string`, `number` or `Date` to a valid `Date` object.
- *
- * @param date The date to convert.
- * @param name The reference name used for error messages. Defaults to `'refDate'`.
- *
- * @throws If the given date is invalid.
- */
-function toDate(date: string | Date | number, name: string = 'refDate'): Date {
- const converted = new Date(date);
-
- if (Number.isNaN(converted.valueOf())) {
- throw new FakerError(`Invalid ${name} date: ${date.toString()}`);
- }
-
- return converted;
-}
-
-/**
* Module to generate dates (without methods requiring localized data).
*/
export class SimpleDateModule extends SimpleModuleBase {