diff --git a/apps/client/src/common/utils/__tests__/time.test.ts b/apps/client/src/common/utils/__tests__/time.test.ts index 3334055c6..0f0c06c64 100644 --- a/apps/client/src/common/utils/__tests__/time.test.ts +++ b/apps/client/src/common/utils/__tests__/time.test.ts @@ -58,4 +58,16 @@ describe('formatDuration()', () => { expect(formatDuration(2 * MILLIS_PER_HOUR + 6 * MILLIS_PER_MINUTE + 45 * MILLIS_PER_SECOND, false)).toBe('2h6m45s'); expect(formatDuration(599702, false)).toBe('9m59s'); }); + it('formats durations differently with and without seconds', () => { + expect(formatDuration(0, false)).toBe('0m'); + expect(formatDuration(0, true)).toBe('0m'); + expect(formatDuration(30 * MILLIS_PER_SECOND, false)).toBe('30s'); + expect(formatDuration(30 * MILLIS_PER_SECOND, true)).toBe(''); + expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, false)).toBe('2h30s'); + expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, true)).toBe('2h'); + expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, false)).toBe( + '2h10m30s', + ); + expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, true)).toBe('2h10m'); + }); }); diff --git a/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory.tsx b/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory.tsx index 9c7a8a463..34c59d411 100644 --- a/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory.tsx +++ b/apps/client/src/views/cuesheet/cuesheet-table/cuesheet-table-elements/cuesheetColsFactory.tsx @@ -105,10 +105,10 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) { return null; } - const { hideTableSeconds } = table.options.meta.options; const event = row.original; if (!isOntimeEvent(event)) { - return {formatDuration(getValue() as number, hideTableSeconds)}; + const duration = getValue() as number; + return {formatDuration(duration, false)}; } const { handleUpdateTimer } = table.options.meta; @@ -117,7 +117,7 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) { const duration = getValue() as number; const isDurationLocked = event.timeStrategy === TimeStrategy.LockDuration; - const formattedDuration = formatDuration(duration, hideTableSeconds); + const formattedDuration = formatDuration(duration, false); const canWrite = column.columnDef.meta?.canWrite; if (!canWrite) {