Skip to content

Commit d07c28b

Browse files
committed
Support negative timestamp
1 parent b0614b5 commit d07c28b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/test/components/__snapshots__/MenuButtons.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ exports[`app/MenuButtons <Publish> matches the snapshot for the menu buttons and
21872187
class="menuButtonsDownloadSize"
21882188
>
21892189
(
2190-
1.58 kB
2190+
1.59 kB
21912191
)
21922192
</span>
21932193
</a>
@@ -2305,7 +2305,7 @@ exports[`app/MenuButtons <Publish> matches the snapshot for the opened panel for
23052305
class="menuButtonsDownloadSize"
23062306
>
23072307
(
2308-
1.56 kB
2308+
1.57 kB
23092309
)
23102310
</span>
23112311
</a>
@@ -2418,7 +2418,7 @@ exports[`app/MenuButtons <Publish> matches the snapshot for the opened panel for
24182418
class="menuButtonsDownloadSize"
24192419
>
24202420
(
2421-
1.58 kB
2421+
1.59 kB
24222422
)
24232423
</span>
24242424
</a>

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)