1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-23 02:42:37 +01:00

allow shortening "ms" part when it's 0

This commit is contained in:
Mikael Finstad 2021-02-21 19:14:31 +01:00
parent 6093acee63
commit 099d046c20
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
3 changed files with 4 additions and 3 deletions

View File

@ -42,7 +42,7 @@ const TimelineSeg = memo(({
const onThisSegClick = () => onSegClick(segNum);
const durationStr = cutEnd > cutStart ? `${formatDuration({ seconds: cutEnd - cutStart })} ` : '';
const durationStr = cutEnd > cutStart ? `${formatDuration({ seconds: cutEnd - cutStart, shorten: true })} ` : '';
const title = `${durationStr}${name}`;
return (

View File

@ -20,7 +20,7 @@ export function formatDuration({ seconds: secondsIn, fileNameFriendly, showMs =
const secondsPadded = padStart(Math.floor(secondsAbs) % 60, 2, '0');
const ms = secondsAbs - Math.floor(secondsAbs);
let msPart = '';
if (showMs) {
if (showMs && !(shorten && ms === 0)) {
const msPadded = fps != null
? padStart(Math.floor(ms * fps), 2, '0')
: padStart(Math.floor(ms * 1000), 3, '0');

View File

@ -8,7 +8,8 @@ it('should format duration properly', () => {
expect(formatDuration({ seconds: 101.5 })).toBe('00:01:41.500');
expect(formatDuration({ seconds: 101.5, shorten: true })).toBe('1:41.500');
expect(formatDuration({ seconds: 10000 })).toBe('02:46:40.000');
expect(formatDuration({ seconds: 10000, shorten: true })).toBe('2:46:40.000');
expect(formatDuration({ seconds: 10000, shorten: true })).toBe('2:46:40');
expect(formatDuration({ seconds: 10000.5, shorten: true })).toBe('2:46:40.500');
expect(formatDuration({ seconds: 101.5, showMs: false })).toBe('00:01:41');
expect(formatDuration({ seconds: 101.5, showMs: false, shorten: true })).toBe('1:41');
});