Skip to content

Commit

Permalink
fix: datetime parsing display value when format not provided (#7181)
Browse files Browse the repository at this point in the history
  • Loading branch information
demshy authored Apr 16, 2024
1 parent 0e6f93b commit 9718772
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/decap-cms-widget-datetime/src/DateTimeControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ class DateTimeControl extends React.Component {
formatInputValue(value) {
if (value === '') return value;
const { format, inputFormat } = this.getFormat();
return this.isUtc
const inputValue = this.isUtc
? dayjs.utc(value, format).format(inputFormat)
: dayjs(value, format).format(inputFormat);

if (this.isValidDate(inputValue)) {
return inputValue;
}
return this.isUtc ? dayjs.utc(value).format(inputFormat) : dayjs(value).format(inputFormat);
}

handleChange = datetime => {
Expand Down

0 comments on commit 9718772

Please sign in to comment.