From 94a4d391c7909c96bac5f5993698499fddc6359d Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 31 May 2022 22:49:05 +0800 Subject: [PATCH] fix(client): datetime with timezone --- .../client/src/schema-component/antd/date-picker/util.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/date-picker/util.ts b/packages/core/client/src/schema-component/antd/date-picker/util.ts index da03ccf94..6b1cce795 100644 --- a/packages/core/client/src/schema-component/antd/date-picker/util.ts +++ b/packages/core/client/src/schema-component/antd/date-picker/util.ts @@ -1,5 +1,6 @@ -import { formatMomentValue, momentable } from '@formily/antd/lib/__builtins__'; +import { formatMomentValue } from '@formily/antd/lib/__builtins__'; import type { DatePickerProps } from 'antd/lib/date-picker'; +import moment from 'moment'; export const getDefaultFormat = (props: DatePickerProps & { dateFormat: string; timeFormat: string }) => { if (props.format) { @@ -30,8 +31,8 @@ export const mapDateFormat = function () { return { ...props, format: format, - - value: momentable(props.value, format === 'YYYY-wo' ? 'YYYY-w' : format), + value: props.value && moment(props.value).isValid() ? moment(props.value) : undefined, + // value: momentable(props.value, format === 'YYYY-wo' ? 'YYYY-w' : format), onChange: (value: moment.Moment | moment.Moment[]) => { if (onChange) { onChange(formatMomentValue(value, format));