diff --git a/src/lib/utilities/format-time.ts b/src/lib/utilities/format-time.ts index 40e907352..a29e924b8 100644 --- a/src/lib/utilities/format-time.ts +++ b/src/lib/utilities/format-time.ts @@ -193,9 +193,11 @@ export function getMilliseconds(date: ValidTime | undefined | null): number { export function fromSecondsToMinutesAndSeconds(seconds: number): string { if (!seconds) return ''; + const start = new Date(Date.UTC(0, 0, 0, 0, 0, 0)); + const end = new Date(Date.UTC(0, 0, 0, 0, 0, Math.floor(seconds))); const duration = intervalToDuration({ - start: 0, - end: Math.floor(seconds) * 1000, + start, + end, }); return durationToString(duration, { format: ['minutes', 'seconds'] }); } diff --git a/src/lib/utilities/to-duration.ts b/src/lib/utilities/to-duration.ts index b169f87f5..66fd38348 100644 --- a/src/lib/utilities/to-duration.ts +++ b/src/lib/utilities/to-duration.ts @@ -137,7 +137,9 @@ export const fromSeconds = ( if (!seconds.endsWith('s')) return ''; if (isNaN(parsedSeconds) || isNaN(parsedDecimal)) return ''; - const duration = intervalToDuration({ start: 0, end: parsedSeconds * 1000 }); + const start = new Date(Date.UTC(0, 0, 0, 0, 0, 0)); + const end = new Date(Date.UTC(0, 0, 0, 0, 0, parsedSeconds)); + const duration = intervalToDuration({ start, end }); const durationString = durationToString(duration, { delimiter }); const milliseconds = Math.round(parsedDecimal * 1000 * 1000000000) / 1000000000; // round to nanoseconds