Skip to content

fix: parse Day.js input with the picker locale - #1013

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-dayjs-locale-parsing
Open

fix: parse Day.js input with the picker locale#1013
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-dayjs-locale-parsing

Conversation

@nrps9909

@nrps9909 nrps9909 commented Sep 5, 2026

Copy link
Copy Markdown

With Day.js globally set to English, a French picker using D MMM YYYY displays 24 août 2026, but editing it to 25 août 2026 and pressing Enter does not commit the value. The adapter parses with the global language and only assigns the requested locale afterward.

Resolve the effective picker locale before strict parsing and pass it to Day.js as a parsing argument. Resolve it through a Day.js instance so an unregistered locale keeps the existing global-language fallback. Parsing never changes the global language.

This addresses the adapter-side input issue described in the review of ant-design/ant-design#59222. It does not change locale registration or the separate Uzbek locale issue.

Validation against base a975a11f9a959a811b1ecd901e8ff8ae8f0e515b:

  • Six regressions fail on the base: French abbreviated/full month names, the fr_BE mapping, alternate formats, English input with a French global language, and a rendered picker keyboard-edit/Enter interaction.
  • All nine added cases pass after the fix, including unregistered-locale fallback and strict rejection of invalid dates/trailing input. Global-language preservation is asserted.
  • Full suite: 15 suites, 481 passed / 2 skipped, and 29 snapshots passed; no snapshots updated.
  • ESM/CJS build and declaration generation pass. Focused Prettier and diff checks pass; ESLint has zero errors and one existing unused-disable warning in tests/picker.spec.tsx.
  • Full lint:tsc reports ten existing deprecated Jest matcher-alias errors in unchanged picker tests. A clean worktree at the base with the same dependencies produces the same ten diagnostics after accounting for inserted-line offsets. No new type errors are introduced; this is not a claim of a clean full-repository type check.

Implemented and validated with OpenAI Codex assistance.

Summary by CodeRabbit

  • Bug 修复
    • 修复按区域设置解析日期时的行为,支持法语等本地化日期格式。
    • 未注册的区域设置继续使用回退行为。
    • 严格日期校验可正确应用指定区域设置,且不会改变全局语言设置。
    • 修复法语环境下日期选择器的月份显示与提交结果。

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 8549fb82-549c-4ec0-b91c-293be7613338

📥 Commits

Reviewing files that changed from the base of the PR and between a975a11 and 52f4917.

📒 Files selected for processing (3)
  • src/generate/dayjs.ts
  • tests/generate.spec.tsx
  • tests/picker.spec.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

本次变更调整 Day.js 的区域解析方式,保留未注册区域的回退行为,并增加生成器与日期选择器的法语解析测试。测试同时验证严格校验和全局 locale 不变。

Changes

Day.js 区域解析

Layer / File(s) Summary
区域解析与严格校验
src/generate/dayjs.ts, tests/generate.spec.tsx
解析时使用 Day.js 实际采用的 locale,并将 locale 直接传入严格解析调用。测试覆盖法语、英语、未注册区域回退、严格校验和全局 locale 保持不变。

日期选择器本地化输入

Layer / File(s) Summary
法语月份文本提交
tests/picker.spec.tsx
测试使用 frFR 渲染并提交法语月份文本,验证日期值、格式化结果、校验状态和全局 dayjs.locale()

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 52f49

Localized picker input is now parsed with the picker locale without changing Day.js’s global locale. The covered parsing and picker submission behavior indicates no remaining merge-blocking risk.

Suggested reviewers: zombiej

Poem

小兔捧来法语月,
Day.js 依 locale 解析。
全局英语仍安静,
严格校验守日期。
轻敲回车值提交,
八月花香留输入框。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: parse Day.js input with the picker locale”准确概括了主要变更:使用 picker locale 解析 Day.js 输入。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (a975a11) to head (52f4917).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1013   +/-   ##
=======================================
  Coverage   98.88%   98.88%           
=======================================
  Files          68       68           
  Lines        2867     2867           
  Branches      822      822           
=======================================
  Hits         2835     2835           
  Misses         29       29           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Successfully merging this pull request may close these issues.

1 participant