Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#670 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
frontend

调研方向

从 src/generate/luxon.ts 开始,在启用 Luxon's Settings.throwOnInvalid 的情况下复现 month-picker 的场景,重点关注 issue 中引用的 parsing 格式。当 picker 对带 padding 和不带 padding 的月份输入都不再抛出错误,同时保留现有的日期行为时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
304
派生
349
平均合并
43 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react-component/picker 的其他 Issue

查看 react-component/picker 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。