Skip to content

Commit 7ff2708

Browse files
committed
Support negative timestamp
1 parent c70f208 commit 7ff2708

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/utils/format-numbers.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,19 @@ export function formatTimestamp(
425425
maxFractionalDigits: number = 3,
426426
// precision is the minimum required precision.
427427
precision: Milliseconds = Infinity
428-
) {
428+
): string {
429+
if (time < 0) {
430+
return (
431+
'-' +
432+
formatTimestamp(
433+
Math.abs(time),
434+
significantDigits,
435+
maxFractionalDigits,
436+
precision
437+
)
438+
);
439+
}
440+
429441
if (precision !== Infinity) {
430442
// Round the values to display nicer numbers when the extra precision
431443
// isn't useful. (eg. show 3h52min10s instead of 3h52min14s)

0 commit comments

Comments
 (0)