ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix secondsToTime rounding
Chocobozzz84f91723472b
diff --git a/packages/core-utils/src/common/date.ts b/packages/core-utils/src/common/date.tsindex be1e36a9c8..5a1c0daa4e 100644--- a/packages/core-utils/src/common/date.ts+++ b/packages/core-utils/src/common/date.ts@@ -104,6 +104,8 @@ export function secondsToTime (options: {if (seconds === 0 && format !== 'full') return '0s'+ seconds = Math.round(seconds)+const formatNumber = (value: number) => {if (format === 'locale-string') return value.toLocaleString()@@ -125,7 +127,7 @@ export function secondsToTime (options: {else if (minutes >= 1) time += formatNumber(minutes) + minuteSymbolelse if (format === 'full') time += '00' + minuteSymbol- seconds = Math.round(seconds) % 60+ seconds %= 60if (seconds >= 1 && seconds < 10 && format === 'full') time += '0' + seconds + secondsSymbolelse if (seconds >= 1) time += formatNumber(seconds) + secondsSymbolelse if (format === 'full') time += '00'diff --git a/packages/tests/src/core-utils/date.ts b/packages/tests/src/core-utils/date.tsindex a0ccda7f8b..df8f897b44 100644--- a/packages/tests/src/core-utils/date.ts+++ b/packages/tests/src/core-utils/date.ts@@ -121,6 +121,11 @@ describe('Seconds to time', function () {expect(secondsToTime(61.6)).to.equals('1m2s')expect(secondsToTime(61.51)).to.equals('1m2s')})++ it('Carries the rounding into minutes/hours when crossing a boundary', function () {+ expect(secondsToTime(59.6)).to.equals('1m')+ expect(secondsToTime(3599.6)).to.equals('1h')+ })})describe('Milliseconds to time', function () {