From 92c6bc12c2e093dfdb896195dfa942a3bda17d81 Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Fri, 29 Sep 2023 13:39:00 +0200 Subject: [PATCH] fix issue with minutes --- assets/components/cards/TimePicker.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/assets/components/cards/TimePicker.tsx b/assets/components/cards/TimePicker.tsx index ae726a6b3..f8391be09 100644 --- a/assets/components/cards/TimePicker.tsx +++ b/assets/components/cards/TimePicker.tsx @@ -27,7 +27,7 @@ export class TimePicker extends React.PureComponent { this.padValue = this.padValue.bind(this); const hour = new Date().toLocaleTimeString([], {hour: 'numeric'}); - this.is12HourFormat = !hour.includes('AM') || !hour.includes('PM'); + this.is12HourFormat = hour.includes('AM') || hour.includes('PM'); } /** @@ -77,18 +77,22 @@ export class TimePicker extends React.PureComponent { const current = this.props.value.split(':'); const updated12HourValue = (() => { - if (parseInt(current[0], 10) >= 12) { - if (newValue === '12') { - return newValue; + if (index === 0) { + if (parseInt(this.props.value.split(':')[0], 10) >= 12) { + if (newValue === '12') { + return newValue; + } else { + return (parseInt(newValue, 10) + 12).toString(); + } } else { - return (parseInt(newValue, 10) + 12).toString(); + if (newValue === '12') { + return '00'; + } else { + return newValue; + } } } else { - if (newValue === '12') { - return '00'; - } else { - return newValue; - } + return newValue; } })();