Skip to content

Commit 9718772

Browse files
authored
fix: datetime parsing display value when format not provided (#7181)
1 parent 0e6f93b commit 9718772

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/decap-cms-widget-datetime/src/DateTimeControl.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ class DateTimeControl extends React.Component {
114114
formatInputValue(value) {
115115
if (value === '') return value;
116116
const { format, inputFormat } = this.getFormat();
117-
return this.isUtc
117+
const inputValue = this.isUtc
118118
? dayjs.utc(value, format).format(inputFormat)
119119
: dayjs(value, format).format(inputFormat);
120+
121+
if (this.isValidDate(inputValue)) {
122+
return inputValue;
123+
}
124+
return this.isUtc ? dayjs.utc(value).format(inputFormat) : dayjs(value).format(inputFormat);
120125
}
121126

122127
handleChange = datetime => {

0 commit comments

Comments
 (0)