We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
prettyTime()
1 parent b8f1be7 commit 5876ca7Copy full SHA for 5876ca7
1 file changed
src/utils.ts
@@ -1,29 +1,5 @@
1
import * as path from "@std/path";
2
3
-const PERIODS = {
4
- year: 365 * 24 * 60 * 60 * 1000,
5
- month: 30 * 24 * 60 * 60 * 1000,
6
- week: 7 * 24 * 60 * 60 * 1000,
7
- day: 24 * 60 * 60 * 1000,
8
- hour: 60 * 60 * 1000,
9
- minute: 60 * 1000,
10
- seconds: 1000,
11
-};
12
-
13
-export function prettyTime(diff: number) {
14
- if (diff > PERIODS.day) {
15
- return Math.floor(diff / PERIODS.day) + "d";
16
- } else if (diff > PERIODS.hour) {
17
- return Math.floor(diff / PERIODS.hour) + "h";
18
- } else if (diff > PERIODS.minute) {
19
- return Math.floor(diff / PERIODS.minute) + "m";
20
- } else if (diff > PERIODS.seconds) {
21
- return Math.floor(diff / PERIODS.seconds) + "s";
22
- }
23
24
- return diff + "ms";
25
-}
26
27
export function assertInDir(
28
filePath: string,
29
dir: string,
0 commit comments