Skip to content

Conversation

@1o1w1
Copy link

@1o1w1 1o1w1 commented Feb 3, 2026

Hi,

This PR addresses the issue where rc-picker crashes when multiple Day.js versions are present due to an implicit dependency on plugins registered on the external Day.js instance.

To fix this, I’ve updated the component to use its own internal Day.js instance with all required plugins explicitly extended. This ensures consistent behavior regardless of the Day.js version or plugin setup in the host app.

The change is non-breaking and has been verified against the provided reproduction case — the RangePicker now works as expected.

For more details, please see: #957

Thanks for your time reviewing!

Summary by CodeRabbit

发布说明

  • 重构
    • 引入内部日期规范化,统一对不同来源的日期值处理,所有读写、比较、格式化与本地化操作均通过该机制执行,保持外部接口不变。
  • 测试
    • 新增用例验证外部日期对象的兼容性,确保年份、月份和日期提取行为稳定。

@vercel
Copy link

vercel bot commented Feb 3, 2026

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

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @1o1w1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a stability issue in rc-picker that occurred when an application used multiple Day.js instances, leading to crashes due to conflicting plugin registrations. The solution involves refactoring the component to use a self-contained Day.js instance, thereby isolating its date manipulation logic and ensuring predictable operation. This enhancement improves the robustness of the component in diverse application environments.

Highlights

  • Dependency Conflict Resolution: Addresses a critical issue where rc-picker would crash when multiple Day.js versions were present in an application, caused by implicit plugin dependencies.
  • Internal Day.js Instance: The component now utilizes its own internal Day.js instance, explicitly extending all necessary plugins to ensure consistent and isolated behavior.
  • Enhanced Stability: This change guarantees that the component functions reliably regardless of the host application's Day.js version or plugin configuration, without introducing any breaking changes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/generate/dayjs.ts
    • Imported isDayjs from 'dayjs' to facilitate type checking.
    • Introduced a new helper function getUDayjs to ensure that all date operations within the component are performed on its internal Day.js instance, converting external Day.js objects if necessary.
    • Modified numerous generateConfig methods (e.g., getEndDate, getWeekDay, addYear, isAfter, format) to leverage the getUDayjs helper, ensuring consistent and isolated date handling throughout the component's date generation logic.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Walkthrough

src/generate/dayjs.ts 中新增内部辅助函数 getUDayjs 并将所有与 Dayjs 相关的获取、设置、格式化、比较与校验操作改为通过该规范化路径执行,同时引入 isDayjs 检查以正确处理已是 Dayjs 的值。 (47 字)

Changes

Cohort / File(s) Summary
Dayjs 实例规范化
src/generate/dayjs.ts
新增 getUDayjs,将所有 getter(如 getEndDate, getWeekDay, getYear 等)、setter(如 addYear, setMonth, setDate, setHour 等)、格式化/解析、比较(isAfter)与校验(isValidate)逻辑改为通过 getUDayjs(date) 统一处理;使用 isDayjs 进行类型守卫;保持公共导出签名不变。
测试
tests/generate.spec.tsx
新增测试用例,验证 getUDayjs 能将外部类似 Dayjs 的对象转换为库内部可用的 Dayjs 实例(检查 getYear/getMonth/getDate)。

Sequence Diagram(s)

(已省略 — 变更为单文件内部规范化,未引入跨组件新交互)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • afc163

诗句

🐰✨ 月光下我轻敲键,
把时刻揉进一行函,
getUDayjs 把乱序寻,
不借外力亦自安,
小兔竖耳庆更新。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题概括了主要变更内容——使用内部dayjs实例以避免隐式依赖,这与代码修改(引入getUDayjs辅助函数)完全相关且准确反映核心目标。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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.

Copy link
Contributor

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

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 aims to isolate the internal Day.js instance to prevent plugin conflicts when multiple versions of the library are present, by wrapping date operations with a getUDayjs utility function. However, a critical data integrity bug was introduced in the conversion logic between external and internal Day.js instances. Specifically, the use of .unix() (seconds) with the dayjs() constructor (milliseconds) causes dates to be incorrectly shifted to 1970, leading to incorrect date conversions. This issue needs to be addressed for correct date processing.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/generate/dayjs.ts`:
- Around line 111-118: getUDayjs incorrectly calls dayjs(value.unix()) which
treats the number as milliseconds while unix() returns seconds, producing wrong
dates for external Dayjs instances; update the conversion to use seconds-aware
parsing by replacing dayjs(value.unix()) with either dayjs.unix(value.unix()) or
dayjs(value.unix() * 1000) so external Dayjs values are converted to the
internal dayjs instance with the correct timestamp (refer to getUDayjs, dayjs,
and value.unix()).

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/generate/dayjs.ts`:
- Line 2: The import of isDayjs from 'dayjs' is not compatible with dayjs v1.x;
update code in src/generate/dayjs.ts to stop using the named import and instead
call the static helper on the default import: replace uses of the named symbol
isDayjs with dayjs.isDayjs(value) (and remove "import { isDayjs } from
'dayjs'"), ensuring checks like "dayjs.isDayjs(value)" and any instanceof checks
use the dayjs default export; alternatively note you can upgrade to dayjs v2.x
if you prefer to keep named imports.

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.80%. Comparing base (6514d60) to head (d83b033).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #958   +/-   ##
=======================================
  Coverage   98.80%   98.80%           
=======================================
  Files          65       65           
  Lines        2680     2684    +4     
  Branches      719      745   +26     
=======================================
+ Hits         2648     2652    +4     
  Misses         29       29           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 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.

@afc163
Copy link
Member

afc163 commented Feb 4, 2026

图片

@1o1w1
Copy link
Author

1o1w1 commented Feb 4, 2026

Test cases have been added

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