Skip to content

Commit

Permalink
MMT-3943: Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gokey committed Nov 20, 2024
1 parent 241937d commit b8cb2f9
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const CustomDateTimeWidget = ({

const { description } = schema

// Parse as a localized date, as the DatePicker is working with localized dates.
const fieldValue = value ? new Date(value) : null

const { formContext } = registry
const {
focusField,
Expand Down Expand Up @@ -83,7 +86,8 @@ const CustomDateTimeWidget = ({
}

const handleChange = (newDate) => {
onChange(newDate.toISOString())
const formattedDateTime = moment(newDate).local().format('YYYY-MM-DDTHH:mm:ss.000')
onChange(`${formattedDateTime}Z`)

handleBlur()
}
Expand All @@ -100,7 +104,7 @@ const CustomDateTimeWidget = ({
<DatePicker
className="w-100 p-2 form-control"
disabled={disabled}
dateFormat="yyyy-MM-dd'T'H:mm:ss.000'Z'"
dateFormat="yyyy-MM-dd'T'HH:mm:ss.000'Z'"
dropdownMode="select"
id={id}
onBlur={handleBlur}
Expand All @@ -110,8 +114,11 @@ const CustomDateTimeWidget = ({
peekNextMonth
placeholderText="YYYY-MM-DDTHH:MM:SSZ"
wrapperClassName="d-block"
selected={(
value && moment.utc(value).toDate())}
selected={
value && new Date(fieldValue.toLocaleString('en-US', {
timeZone: 'GMT'
}))
}
showMonthDropdown
showYearDropdown
showTimeSelect
Expand Down

0 comments on commit b8cb2f9

Please sign in to comment.