mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-25 08:59:13 +00:00
Add option to display the full time (HH:mm:ss) in the timer view (#988)
* Add option to display the full time (HH:mm:ss) in the timer view Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> --------- Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,14 @@ const hideTimerSeconds: ParamField = {
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showLeadingZeros: ParamField = {
|
||||||
|
id: 'showLeadingZeros',
|
||||||
|
title: 'Show leading zeros in timer',
|
||||||
|
description: 'Whether to show leading zeros in the running timer',
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: false,
|
||||||
|
};
|
||||||
|
|
||||||
export const getClockOptions = (timeFormat: string): ParamField[] => [
|
export const getClockOptions = (timeFormat: string): ParamField[] => [
|
||||||
getTimeOption(timeFormat),
|
getTimeOption(timeFormat),
|
||||||
{
|
{
|
||||||
@@ -107,6 +115,7 @@ export const getTimerOptions = (timeFormat: string, customFields: CustomFields):
|
|||||||
return [
|
return [
|
||||||
getTimeOption(timeFormat),
|
getTimeOption(timeFormat),
|
||||||
hideTimerSeconds,
|
hideTimerSeconds,
|
||||||
|
showLeadingZeros,
|
||||||
{
|
{
|
||||||
id: 'hideClock',
|
id: 'hideClock',
|
||||||
title: 'Hide Time Now',
|
title: 'Hide Time Now',
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ export function getFormattedTimer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let display = millisToString(timeToParse);
|
let display = millisToString(timeToParse);
|
||||||
display = removeLeadingZero(display);
|
if (options.removeLeadingZero) {
|
||||||
|
display = removeLeadingZero(display);
|
||||||
|
}
|
||||||
|
|
||||||
if (options.removeSeconds) {
|
if (options.removeSeconds) {
|
||||||
display = formatDisplayWithMinutes(display, localisedMinutes);
|
display = formatDisplayWithMinutes(display, localisedMinutes);
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
hideMessage: false,
|
hideMessage: false,
|
||||||
hideTimerSeconds: false,
|
hideTimerSeconds: false,
|
||||||
hideClockSeconds: false,
|
hideClockSeconds: false,
|
||||||
|
removeLeadingZeros: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const hideClock = searchParams.get('hideClock');
|
const hideClock = searchParams.get('hideClock');
|
||||||
@@ -97,6 +98,9 @@ export default function Timer(props: TimerProps) {
|
|||||||
const hideTimerSeconds = searchParams.get('hideTimerSeconds');
|
const hideTimerSeconds = searchParams.get('hideTimerSeconds');
|
||||||
userOptions.hideTimerSeconds = isStringBoolean(hideTimerSeconds);
|
userOptions.hideTimerSeconds = isStringBoolean(hideTimerSeconds);
|
||||||
|
|
||||||
|
const showLeadingZeros = searchParams.get('showLeadingZeros');
|
||||||
|
userOptions.removeLeadingZeros = !isStringBoolean(showLeadingZeros);
|
||||||
|
|
||||||
const secondarySource = searchParams.get('secondary-src');
|
const secondarySource = searchParams.get('secondary-src');
|
||||||
const secondaryTextNow = getPropertyValue(eventNow, secondarySource);
|
const secondaryTextNow = getPropertyValue(eventNow, secondarySource);
|
||||||
const secondaryTextNext = getPropertyValue(eventNext, secondarySource);
|
const secondaryTextNext = getPropertyValue(eventNext, secondarySource);
|
||||||
@@ -126,7 +130,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
const stageTimer = getTimerByType(viewSettings.freezeEnd, time);
|
const stageTimer = getTimerByType(viewSettings.freezeEnd, time);
|
||||||
const display = getFormattedTimer(stageTimer, time.timerType, getLocalizedString('common.minutes'), {
|
const display = getFormattedTimer(stageTimer, time.timerType, getLocalizedString('common.minutes'), {
|
||||||
removeSeconds: userOptions.hideTimerSeconds,
|
removeSeconds: userOptions.hideTimerSeconds,
|
||||||
removeLeadingZero: true,
|
removeLeadingZero: userOptions.removeLeadingZeros,
|
||||||
});
|
});
|
||||||
|
|
||||||
const stageTimerCharacters = display.replace('/:/g', '').length;
|
const stageTimerCharacters = display.replace('/:/g', '').length;
|
||||||
|
|||||||
Reference in New Issue
Block a user