Skip to content

fix(date-picker,date-panel):fix the issue where the selected date is offset by one day in multi-time zone scenarios. - #4266

Merged
zzcr merged 1 commit into
opentiny:devfrom
discreted66:dev-0726
Jul 27, 2026
Merged

fix(date-picker,date-panel):fix the issue where the selected date is offset by one day in multi-time zone scenarios.#4266
zzcr merged 1 commit into
opentiny:devfrom
discreted66:dev-0726

Conversation

@discreted66

@discreted66 discreted66 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

删除 modelValue watcher 中错误的 val - localOffset 时区偏移,改为按输入类型(字符串取 UTC 分量、Date/Number 取本地分量)正确提取日历日期,修复西半球时区下日期选中与高亮偏移一天的问题。

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes
    • Fixed date panel value handling to better preserve the selected month and year across time zones.
    • Prevented UTC-based inputs from being normalized in a way that could cause dates to shift or land on the wrong day.

@github-actions github-actions Bot added the bug Something isn't working label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The date panel’s modelValue watcher now derives date components directly from the parsed value, using UTC components for strings and local components otherwise, while removing the timezone-offset conversion and extra-day adjustment.

Changes

Date normalization

Layer / File(s) Summary
Update model value normalization
packages/renderless/src/date-panel/vue.ts
The watcher selects UTC or local date components based on the input type and passes them to modifyDate without adding an extra day.

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

Possibly related PRs

Suggested labels: bug

Poem

I’m a rabbit with dates in my den,
No extra day sneaks in again.
UTC or local, the parts align,
Each little calendar hop is fine.
🐇📅

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main fix: correcting one-day date offset issues in date picker/panel multi-time-zone scenarios.
✨ Finishing Touches
🧪 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.

@discreted66 discreted66 changed the title fix(date-panel): 修复多时区场景下选中日期偏移一天的问题 fix(date-panel):fix the issue where the selected date is offset by one day in multi-time zone scenarios. Jul 27, 2026
@discreted66 discreted66 changed the title fix(date-panel):fix the issue where the selected date is offset by one day in multi-time zone scenarios. fix(date-picker,date-panel):fix the issue where the selected date is offset by one day in multi-time zone scenarios. Jul 27, 2026
预补偿 val - localOffset 后混用本地 getFullYear/getMonth 与 UTC 的 getUTCDate+1,导致所有时区偏移一天。

本地与 UTC 混用还会使西半球跨年/跨月边界错月错年。

改为统一读取 getUTCFullYear/getUTCMonth/getUTCDate,与预补偿语义一致,修正多时区及跨边界日期偏移。
@zzcr
zzcr merged commit 4be1cdf into opentiny:dev Jul 27, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants