Centralize date/time formatting utilities (#11831)
This commit is contained in:
@@ -244,19 +244,6 @@ function stripQuotes(value: string): string {
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function formatDuration(ms: number) {
|
||||
if (ms < 1000) {
|
||||
return `${ms}ms`;
|
||||
}
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
if (seconds < 60) {
|
||||
return `${seconds}s`;
|
||||
}
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const rem = seconds % 60;
|
||||
return `${minutes}m${rem.toString().padStart(2, "0")}s`;
|
||||
}
|
||||
|
||||
export function pad(str: string, width: number) {
|
||||
if (str.length >= width) {
|
||||
return str;
|
||||
|
||||
Reference in New Issue
Block a user