Skip to content

fix: align meridiem labels with 12-hour periods#974

Merged
afc163 merged 1 commit into
react-component:masterfrom
QDyanbing:fix-58286-time-picker-meridiem
Jun 10, 2026
Merged

fix: align meridiem labels with 12-hour periods#974
afc163 merged 1 commit into
react-component:masterfrom
QDyanbing:fix-58286-time-picker-meridiem

Conversation

@QDyanbing

@QDyanbing QDyanbing commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • format the 12-hour meridiem column with 9:00 and 15:00 sample times
  • make Chinese cellMeridiemFormat: A render generic 上午 / 下午 labels instead of 早上 / 晚上
  • update the meridiem locale expectation

Root Cause

The time panel used 6:00 and 18:00 as sample dates for formatting AM/PM labels. In Chinese locales those hours map to 早上 and 晚上, while selected values such as 13:00 format as 下午, causing the panel label and input value to diverge.

Testing

  • npm test -- tests/new-range.spec.tsx --runInBand
  • npm run lint:tsc
  • git diff --check

Ref: ant-design/ant-design#58286

Summary by CodeRabbit

发布说明

  • Bug 修复

    • 修复时间选择器中上午/下午显示文本的准确性和一致性,提升用户体验的清晰度。
  • 测试

    • 更新相关的测试用例,确保其与新的文本显示相适应。

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

概览

TimePanelBody 将用于生成 AM/PM 上下午标签的示例日期中的小时值从 6/18 更改为 9/15,对应的测试断言也进行了更新。

变更

Meridiem 标签时间调整

层级 / 文件(s) 摘要
AM/PM 标签小时调整及测试
src/PickerPanel/TimePanel/TimePanelBody/index.tsxtests/new-range.spec.tsx
TimePanelBody 将 meridiem 日期生成的基础小时值从 6/18 改为 9/15,对应的测试断言也随之更新以验证新的格式化输出。

估计代码审查工作量

🎯 1 (平凡) | ⏱️ ~3 分钟

建议审查者

  • zombieJ

🐰 小时数字换一换,
九点十五更亮眼,
上午下午标签清,
测试齐心来验证,
时间选择更精准!

🚥 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%. 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 标题准确概括了变更的主要内容:调整meridiem标签以与12小时制周期对齐,涵盖了从样本时间6/18改为9/15,以及相应中文标签更新的核心改动。
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/PickerPanel/TimePanel/TimePanelBody/index.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

tests/new-range.spec.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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 and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the hour values used to generate AM and PM dates in the TimePanelBody component, changing AM from 6 to 9 and PM from 18 to 15. Additionally, the corresponding test assertions in new-range.spec.tsx have been updated to reflect the new Chinese localization strings ('上午' and '下午'). There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@QDyanbing QDyanbing marked this pull request as ready for review June 10, 2026 01:46
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (9a39561) to head (03bcfaf).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #974   +/-   ##
=======================================
  Coverage   98.81%   98.81%           
=======================================
  Files          65       65           
  Lines        2695     2695           
  Branches      724      724           
=======================================
  Hits         2663     2663           
  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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/PickerPanel/TimePanel/TimePanelBody/index.tsx (1)

117-118: 💤 Low value

建议添加注释说明小时值的选择理由。

为了提高代码的可维护性,建议添加简短注释解释为何选择 9 和 15 作为样本小时值。这有助于未来的维护者理解设计决策。

📝 建议的注释
     const base = generateConfig.getNow();
+    // Use 9:00 and 15:00 as sample times to ensure generic AM/PM labels
+    // (e.g., "上午"/"下午" in Chinese, avoiding time-specific variants like "早上"/"晚上")
     const amDate = generateConfig.setHour(base, 9);
     const pmDate = generateConfig.setHour(base, 15);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/PickerPanel/TimePanel/TimePanelBody/index.tsx` around lines 117 - 118,
Add a short inline comment explaining why 9 and 15 were chosen for sample hours:
update the lines that create amDate and pmDate (using
generateConfig.setHour(base, 9) and generateConfig.setHour(base, 15)) to include
a concise note about the decision (e.g., representing typical AM/PM midday
samples or avoiding DST edge cases), so future maintainers understand the
rationale.
tests/new-range.spec.tsx (1)

333-341: ⚡ Quick win

测试断言更新正确,建议考虑增加跨语言环境的测试覆盖。

测试期望值已正确更新为 '上午''下午',与源代码的更改保持一致。当前测试针对中文语言环境验证了修复效果。

为了确保更改在所有支持的语言环境下都能正常工作,建议考虑添加针对其他语言环境(如英语、阿拉伯语等)的类似测试用例,验证小时 9 和 15 在这些语言环境下也能产生正确的 AM/PM 标签。

💡 示例:英语语言环境测试
it('cellMeridiemFormat should work for en_US', () => {
  render(
    <DayRangePicker
      picker="time"
      locale={{
        ...en_US,
        cellMeridiemFormat: 'A',
      }}
      showTime={{
        use12Hours: true,
      }}
      open
    />,
  );

  expect(
    document.querySelectorAll('[data-type="meridiem"] .rc-picker-time-panel-cell')[0]
      .textContent,
  ).toEqual('AM');
  expect(
    document.querySelectorAll('[data-type="meridiem"] .rc-picker-time-panel-cell')[1]
      .textContent,
  ).toEqual('PM');
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/new-range.spec.tsx` around lines 333 - 341, The test currently asserts
Chinese meridiem labels ('上午'/'下午') in tests/new-range.spec.tsx for
DayRangePicker; add parallel test cases that render DayRangePicker with
alternate locales (e.g., en_US with cellMeridiemFormat: 'A' and an RTL or other
locale) and showTime.use12Hours=true, then assert the meridiem cell texts are
'AM'/'PM' (and appropriate RTL labels) to ensure cross-language coverage; locate
test block referencing '[data-type="meridiem"] .rc-picker-time-panel-cell' and
duplicate with different locale props to validate outputs across languages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/PickerPanel/TimePanel/TimePanelBody/index.tsx`:
- Around line 117-118: Add a short inline comment explaining why 9 and 15 were
chosen for sample hours: update the lines that create amDate and pmDate (using
generateConfig.setHour(base, 9) and generateConfig.setHour(base, 15)) to include
a concise note about the decision (e.g., representing typical AM/PM midday
samples or avoiding DST edge cases), so future maintainers understand the
rationale.

In `@tests/new-range.spec.tsx`:
- Around line 333-341: The test currently asserts Chinese meridiem labels
('上午'/'下午') in tests/new-range.spec.tsx for DayRangePicker; add parallel test
cases that render DayRangePicker with alternate locales (e.g., en_US with
cellMeridiemFormat: 'A' and an RTL or other locale) and
showTime.use12Hours=true, then assert the meridiem cell texts are 'AM'/'PM' (and
appropriate RTL labels) to ensure cross-language coverage; locate test block
referencing '[data-type="meridiem"] .rc-picker-time-panel-cell' and duplicate
with different locale props to validate outputs across languages.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04f1f28a-4534-4c92-b52e-b5efb4a552d9

📥 Commits

Reviewing files that changed from the base of the PR and between 9a39561 and 03bcfaf.

📒 Files selected for processing (2)
  • src/PickerPanel/TimePanel/TimePanelBody/index.tsx
  • tests/new-range.spec.tsx

@afc163 afc163 merged commit 05ee3fa into react-component:master Jun 10, 2026
7 of 8 checks passed
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.

2 participants