do to formatters
This commit is contained in:
24
apps/website/lib/formatters/DurationFormatter.ts
Normal file
24
apps/website/lib/formatters/DurationFormatter.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* DurationDisplay
|
||||
*
|
||||
* Deterministic formatting for time durations.
|
||||
*/
|
||||
|
||||
export class DurationFormatter {
|
||||
/**
|
||||
* Formats milliseconds as "123.45ms".
|
||||
*/
|
||||
static formatMs(ms: number): string {
|
||||
return `${ms.toFixed(2)}ms`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats seconds as "M:SS.mmm".
|
||||
* Example: 65.123 -> "1:05.123"
|
||||
*/
|
||||
static formatSeconds(seconds: number): string {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const remainingSeconds = (seconds % 60).toFixed(3);
|
||||
return `${minutes}:${remainingSeconds.padStart(6, '0')}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user