From f748ad35e05a10a2c9b654f432c07cc5f612ca54 Mon Sep 17 00:00:00 2001 From: ElementalAlchemist Date: Thu, 14 Nov 2024 04:53:04 -0600 Subject: [PATCH] Fix losing milliseconds sometimes --- thrimbletrimmer/src/common/convertTime.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/thrimbletrimmer/src/common/convertTime.tsx b/thrimbletrimmer/src/common/convertTime.tsx index 29a148f..0002bd9 100644 --- a/thrimbletrimmer/src/common/convertTime.tsx +++ b/thrimbletrimmer/src/common/convertTime.tsx @@ -37,7 +37,7 @@ function dateTimeMathObjectFromBusTime(busTime: string): DateTimeMathObject | nu const parts = busTime.split(":", 3); const hours = parseInt(parts[0], 10) * direction; const minutes = parts.length > 1 ? parseInt(parts[1], 10) * direction : 0; - const seconds = parts.length > 2 ? parseInt(parts[2], 10) * direction : 0; + const seconds = parts.length > 2 ? +parts[2] * direction : 0; return { hours: hours, minutes: minutes, seconds: seconds }; } @@ -69,7 +69,7 @@ export function dateTimeFromTimeAgo(timeAgo: string): DateTime | null { return null; } const nextProp = properties.pop(); - const partNumber = parseInt(nextPart, 10); + const partNumber = +nextPart; if (isNaN(partNumber)) { return null; } @@ -91,7 +91,7 @@ export function timeAgoFromDateTime(dateTime: DateTime): string { timeAgoSeconds = -timeAgoSeconds; } - const seconds = (((timeAgoSeconds % 60) * 1000) | 0) / 1000; + const seconds = Math.floor((timeAgoSeconds % 60) * 1000) / 1000; const secondsString = seconds < 10 ? `0${seconds}` : seconds.toString(); const minutes = (timeAgoSeconds / 60) % 60 | 0; const minutesString = minutes < 10 ? `0${minutes}` : minutes.toString();