From 73d75835e18a33c7f6c1b09bbcef93b16a7a9bfa Mon Sep 17 00:00:00 2001 From: Thomas Grothe Date: Thu, 30 Apr 2026 00:53:13 -0400 Subject: redo timeplot web --- web-timeplot/src/utils-format.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 web-timeplot/src/utils-format.js (limited to 'web-timeplot/src/utils-format.js') diff --git a/web-timeplot/src/utils-format.js b/web-timeplot/src/utils-format.js new file mode 100644 index 0000000..f4eac88 --- /dev/null +++ b/web-timeplot/src/utils-format.js @@ -0,0 +1,22 @@ +export function formatDuration(ms) { + const totalSeconds = Math.max(0, ms / 1000); + if (totalSeconds < 60) { + return `${totalSeconds.toFixed(2)}s`; + } + + const minutes = Math.floor(totalSeconds / 60); + const seconds = totalSeconds % 60; + return `${minutes}m ${seconds.toFixed(1)}s`; +} + +export function formatWallClock(timestampMs) { + return new Intl.DateTimeFormat(undefined, { + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + }).format(new Date(timestampMs)); +} + +export function formatValue(value) { + return Number.isFinite(value) ? value.toFixed(3) : '—'; +} -- cgit v1.2.3