Skip to content

Commit

Permalink
fix: fix formatInputValue ignoring format (#7170)
Browse files Browse the repository at this point in the history
  • Loading branch information
demshy committed Apr 11, 2024
1 parent d3678b0 commit 0b4b1cb
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/decap-cms-widget-datetime/src/DateTimeControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,9 @@ class DateTimeControl extends React.Component {
formatInputValue(value) {
if (value === '') return value;
const { format, inputFormat } = this.getFormat();
let formattedValue = this.isUtc
? dayjs.utc(value).format(inputFormat)
: dayjs(value).format(inputFormat);
if (!this.isValidDate(formattedValue)) {
formattedValue = this.isUtc
? dayjs.utc(value, format).format(inputFormat)
: dayjs(value, format).format(inputFormat);
}
return formattedValue;
return this.isUtc
? dayjs.utc(value, format).format(inputFormat)
: dayjs(value, format).format(inputFormat);
}

handleChange = datetime => {
Expand Down

0 comments on commit 0b4b1cb

Please sign in to comment.