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:
parent
6093acee63
commit
099d046c20
@ -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 (
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user