From 0b4b1cbdaf9da623f115633b86c67015921453b0 Mon Sep 17 00:00:00 2001 From: Anze Demsar Date: Thu, 11 Apr 2024 10:23:32 +0200 Subject: [PATCH] fix: fix formatInputValue ignoring format (#7170) --- .../decap-cms-widget-datetime/src/DateTimeControl.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/decap-cms-widget-datetime/src/DateTimeControl.js b/packages/decap-cms-widget-datetime/src/DateTimeControl.js index 42d456bc38bc..beed9b15c5b2 100644 --- a/packages/decap-cms-widget-datetime/src/DateTimeControl.js +++ b/packages/decap-cms-widget-datetime/src/DateTimeControl.js @@ -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 => {