From b8cb2f92aeb92087da9c64800b089e83bf2698ad Mon Sep 17 00:00:00 2001 From: Christopher Gokey Date: Tue, 19 Nov 2024 19:59:44 -0500 Subject: [PATCH] MMT-3943: Fixed tests --- .../CustomDateTimeWidget/CustomDateTimeWidget.jsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/static/src/js/components/CustomDateTimeWidget/CustomDateTimeWidget.jsx b/static/src/js/components/CustomDateTimeWidget/CustomDateTimeWidget.jsx index 86773007b..bd23d6ab0 100644 --- a/static/src/js/components/CustomDateTimeWidget/CustomDateTimeWidget.jsx +++ b/static/src/js/components/CustomDateTimeWidget/CustomDateTimeWidget.jsx @@ -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, @@ -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() } @@ -100,7 +104,7 @@ const CustomDateTimeWidget = ({