Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker format error without keepOffset #187

Open
skykingit opened this issue Apr 23, 2021 · 1 comment
Open

DatePicker format error without keepOffset #187

skykingit opened this issue Apr 23, 2021 · 1 comment

Comments

@skykingit
Copy link

When i use the datetime ,i found the value is not the current local time
so i see your github code ,i found you transfer date to ISOString by toISOString function,
but i can set the props "keepOffset" to prevent the transfer
when i set keepOffset true,it did't work
so i see you node_modules source code ,you just delete the props "keepOffset"
i am so angry, your code is different between github and node_module

.......................................................
the github code is below :
formik-antd/src/date-picker/index.tsx

export const DatePicker = ({
name,
validate,
onChange,
fast,
keepOffset,
...restProps
}: DatePickerProps) => (

{({
field: { value },
form: { setFieldValue, setFieldTouched },
}: FieldProps) => (
<$DatePicker
value={value ? moment(value) : undefined}
onChange={(date, dateString) => {
setFieldValue(name, date ? date.toISOString(keepOffset) : null)
setFieldTouched(name, true, false)
onChange && onChange(date, dateString)
}}
{...restProps}
/>
)}

)

export default DatePicker


the node_module code is

export const DatePicker = ({
name,
validate,
onChange,
fast,
...restProps
}: DatePickerProps) => (

{({
field: { value },
form: { setFieldValue, setFieldTouched },
}: FieldProps) => (
<$DatePicker
value={value ? moment(value) : undefined}
onChange={(date, dateString) => {
setFieldValue(name, date ? date.toISOString() : null)
setFieldTouched(name, true, false)
onChange && onChange(date, dateString)
}}
{...restProps}
/>
)}

)

export default DatePicker

@jannikbuschke
Copy link
Owner

this repos master branch is probably ahead of the version you have installed.

Check https://www.npmjs.com/package/formik-antd for the latest version. 2.1.0-beta.5 might solve your problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants