aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-03-25 16:45:16 +0100
committerGitHub <[email protected]>2022-03-25 16:45:16 +0100
commitba3c62fca76fe2dc9fd1c8c9292c5333bf2c10a7 (patch)
treea03fd86057314b26229cd628bdbeb1921e46d710 /src
parent3252c7ea0421ead864fd41f4239e1b80f22c29bf (diff)
downloadfaker-ba3c62fca76fe2dc9fd1c8c9292c5333bf2c10a7.tar.xz
faker-ba3c62fca76fe2dc9fd1c8c9292c5333bf2c10a7.zip
refactor: deprecate time.recent (#661)
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) {