react-component / react-component/picker
Picker with Luxon config raises "Error: Invalid DateTime: unparsable: the input "2023-1-01" can't be parsed as format yyyy-MM-dd"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 304
- Forks
- 345
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 7
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/generate/luxon.ts and reproduce the month-picker case with Luxon's Settings.throwOnInvalid enabled, focusing on the parsing format cited in the issue. Done means the picker no longer raises for both padded and non-padded month inputs while preserving the existing date behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100