-
-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75bebff
commit 36b1080
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export class Time { | ||
/** | ||
* recent | ||
* | ||
* @method faker.time.recent | ||
* @param outputType 'abbr' || 'wide' || 'unix' (default choice) | ||
*/ | ||
recent(outputType: 'abbr' | 'wide' | 'unix' = 'unix'): string | number { | ||
let date: string | number | Date = new Date(); | ||
|
||
switch (outputType) { | ||
case 'abbr': | ||
date = date.toLocaleTimeString(); | ||
break; | ||
case 'wide': | ||
date = date.toTimeString(); | ||
break; | ||
case 'unix': | ||
// TODO @Shinigami92 2022-01-10: add default case | ||
date = date.getTime(); | ||
break; | ||
} | ||
|
||
return date; | ||
} | ||
} |