Skip to content

Commit

Permalink
MMT-3943: Updated to support times in UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gokey committed Nov 19, 2024
1 parent c84acf9 commit 241937d
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ const CustomDateTimeWidget = ({

const { description } = schema

const dateWithZone = moment.utc(value).format('YYYY-MM-DDTHH:mm:ss.SSS')
const fieldValue = new Date(dateWithZone)

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

const handleChange = (newDate) => {
let formattedDateTime = newDate.toISOString()
formattedDateTime = `${formattedDateTime.substring(0, 10)}T00:00:00.000Z`
onChange(formattedDateTime)
onChange(newDate.toISOString())

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

0 comments on commit 241937d

Please sign in to comment.