Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef7226c

Browse files
committed
Fix format
1 parent eb45395 commit ef7226c

File tree

1 file changed

+12
-13
lines changed
  • site/src/modules/workspaces/WorkspaceTiming/Chart

1 file changed

+12
-13
lines changed

site/src/modules/workspaces/WorkspaceTiming/Chart/utils.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,29 @@ export const makeTicks = (time: number) => {
6161
};
6262

6363
export const formatTime = (time: number): string => {
64-
const seconds = Math.floor((time / 1000) % 60);
65-
const minutes = Math.floor((time / (1000 * 60)) % 60);
66-
const hours = Math.floor((time / (1000 * 60 * 60)) % 24);
67-
const days = Math.floor(time / (1000 * 60 * 60 * 24));
68-
69-
const timeParts = [];
64+
const seconds = Math.floor(time / 1000);
65+
const minutes = Math.floor(seconds / 60);
66+
const hours = Math.floor(minutes / 60);
67+
const days = Math.floor(hours / 24);
7068

69+
const parts: string[] = [];
7170
if (days > 0) {
72-
timeParts.push(`${days} day${days > 1 ? "s" : ""}`);
71+
parts.push(`${days}d`);
7372
}
7473
if (hours > 0) {
75-
timeParts.push(`${hours} hour${hours > 1 ? "s" : ""}`);
74+
parts.push(`${hours % 24}h`);
7675
}
7776
if (minutes > 0) {
78-
timeParts.push(`${minutes} minute${minutes > 1 ? "s" : ""}`);
77+
parts.push(`${minutes % 60}m`);
7978
}
8079
if (seconds > 0) {
81-
timeParts.push(`${seconds}s`);
80+
parts.push(`${seconds % 60}s`);
8281
}
83-
if (time > 0 && time < 1000) {
84-
timeParts.push(`${time}ms`);
82+
if (time % 1000 > 0) {
83+
parts.push(`${time % 1000}ms`);
8584
}
8685

87-
return timeParts.join(", ");
86+
return parts.join(" ");
8887
};
8988

9089
export const calcOffset = (range: TimeRange, baseRange: TimeRange): number => {

0 commit comments

Comments
 (0)