Skip to content

Commit

Permalink
fix: Consider language specifics when parsing time
Browse files Browse the repository at this point in the history
Closes #946
  • Loading branch information
meltyshev committed Nov 16, 2024
1 parent b700c30 commit 71d0815
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions client/src/components/DueDateEditStep/DueDateEditStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,26 @@ const DueDateEditStep = React.memo(({ defaultValue, onUpdate, onBack, onClose })
return;
}

const value = parseTime(data.time, nullableDate);
let value = t('format:dateTime', {
postProcess: 'parseDate',
value: `${data.date} ${data.time}`,
});

if (Number.isNaN(value.getTime())) {
timeField.current.select();
return;
value = parseTime(data.time, nullableDate);

if (Number.isNaN(value.getTime())) {
timeField.current.select();
return;
}
}

if (!defaultValue || value.getTime() !== defaultValue.getTime()) {
onUpdate(value);
}

onClose();
}, [defaultValue, onUpdate, onClose, data, nullableDate]);
}, [defaultValue, onUpdate, onClose, data, nullableDate, t]);

const handleClearClick = useCallback(() => {
if (defaultValue) {
Expand Down

0 comments on commit 71d0815

Please sign in to comment.