Skip to content

Commit c8cbca2

Browse files
committed
refactor: add floorTime param to formatDiffToTimecodeOverUnder, replace 4 call sites
1 parent 9162217 commit c8cbca2

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/webui/src/client/lib/Components/CounterComponents.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const OverUnderClockComponent = (props: OverUnderProps): JSX.Element => {
99
return (
1010
<div className="counter-component__over-under">
1111
<span className={props.value < 0 ? 'under' : 'over'}>
12-
{RundownUtils.formatDiffToTimecode(props.value, true, false, true, true, true, undefined, true, true)}
12+
{RundownUtils.formatDiffToTimecodeOverUnder(props.value, true)}
1313
</span>
1414
</div>
1515
)
@@ -26,15 +26,15 @@ export const PlannedEndComponent = (props: OverUnderProps): JSX.Element => {
2626
export const TimeToPlannedEndComponent = (props: OverUnderProps): JSX.Element => {
2727
return (
2828
<span className="counter-component__time-to-planned-end">
29-
{RundownUtils.formatDiffToTimecode(props.value, true, false, true, true, true, undefined, true, true)}
29+
{RundownUtils.formatDiffToTimecodeOverUnder(props.value, true)}
3030
</span>
3131
)
3232
}
3333

3434
export const TimeSincePlannedEndComponent = (props: OverUnderProps): JSX.Element => {
3535
return (
3636
<span className="counter-component__time-since-planned-end">
37-
{RundownUtils.formatDiffToTimecode(props.value, true, false, true, true, true, undefined, true, true)}
37+
{RundownUtils.formatDiffToTimecodeOverUnder(props.value, true)}
3838
</span>
3939
)
4040
}

packages/webui/src/client/lib/rundown.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,10 @@ export namespace RundownUtils {
289289
/**
290290
* Format an over/under diff (ms) with "+" for positive, en-dash for negative, smart-floor rounding,
291291
* and smart-hours. Used for start-time diffs and over/under clocks.
292+
* Pass `floorTime: true` to use hard-floor rounding (display won't jump ahead of the actual value).
292293
*/
293-
export function formatDiffToTimecodeOverUnder(milliseconds: number): string {
294-
return formatDiffToTimecode(milliseconds, true, false, true, true, true)
294+
export function formatDiffToTimecodeOverUnder(milliseconds: number, floorTime?: boolean): string {
295+
return formatDiffToTimecode(milliseconds, true, false, true, true, true, undefined, floorTime, floorTime)
295296
}
296297

297298
export function isInsideViewport(

packages/webui/src/client/ui/RundownView/RundownTiming/PlaylistEndTiming.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function PlaylistEndTiming({
5555
role="timer"
5656
>
5757
{!hideDiffLabel && <span className="timing-clock-label right">{t('Diff')}</span>}
58-
{RundownUtils.formatDiffToTimecode(overUnderClock, true, false, true, true, true, undefined, true, true)}
58+
{RundownUtils.formatDiffToTimecodeOverUnder(overUnderClock, true)}
5959
</span>
6060
) : null
6161
) : null}

0 commit comments

Comments
 (0)