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

Picker with Luxon config raises "Error: Invalid DateTime: unparsable: the input "2023-1-01" can't be parsed as format yyyy-MM-dd" #670

Open
JustinAimiable opened this issue Aug 25, 2023 · 0 comments

Comments

@JustinAimiable
Copy link

rc-picker version: 3.8.1
antd version: 5.6.0
luxon version: 3.3.0

When we set the luxon config to Settings.throwOnInvalid = true we get an error when we open up the antd date range picker (using "month" picker)
I don't deeply understand the rc-picker code, but a few things stuck out to me:
the luxon code is parsing using a "yyyy-MM-dd" format while dayjs seems to allow for both padded and non-padded month ['YYYY-M-DD', 'YYYY-MM-DD']

This doesn't really cause issues if we ignore the error, so our workaround is to change that throwOnInvalid setting, but we would strongly prefer for parsing errors to throw. This may be an issue with antd's picker and could raise the issue there if you think that's better, but I do think the config generation for different libraries should have the same behavior. If dayjs accepts that format, then it seems like luxon also should accept it. I did a quick test and I believe "yyyy-M-dd" will work for both 2023-1-01 and 2023-01-01 cases, so that is potentially a simple fix if this doesn't have other side effects.

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

1 participant