Skip to content

Commit

Permalink
fix issue with minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Sep 29, 2023
1 parent ed1d9fb commit 92c6bc1
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions assets/components/cards/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TimePicker extends React.PureComponent<IProps> {
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');
}

/**
Expand Down Expand Up @@ -77,18 +77,22 @@ export class TimePicker extends React.PureComponent<IProps> {
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;
}
})();

Expand Down

0 comments on commit 92c6bc1

Please sign in to comment.