aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/time.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/time.ts b/src/time.ts
index 2d376839..06a32021 100644
--- a/src/time.ts
+++ b/src/time.ts
@@ -2,6 +2,8 @@ import type { LiteralUnion } from './faker';
/**
* Module to generate time of dates in various formats.
+ *
+ * @deprecated You should stop using this module, as it will be removed in the future.
*/
export class Time {
/**
@@ -20,11 +22,20 @@ export class Time {
* faker.time.recent('date') // 2022-03-01T20:35:47.402Z
* faker.time.recent('wide') // '00:34:11 GMT+0100 (Central European Standard Time)'
* faker.time.recent('unix') // 1643067231856
+ *
+ * @deprecated You should stop using this function, as it will be removed in the future. Use the native `new Date()` with one of the wanted functions directly.
*/
recent(
format: LiteralUnion<'abbr' | 'date' | 'wide' | 'unix'> = 'unix'
): string | number | Date {
- // TODO ST-DDT 2022-03-01: Deprecate for removal - #557
+ console.warn(
+ `Deprecation Warning: faker.time.recent() is deprecated. Use the native \`new Date()\` and call the function you want on it.
+ abbr => toLocaleTimeString()
+ wide => toTimeString()
+ unix => getTime()
+`
+ );
+
let date: string | number | Date = new Date();
switch (format) {