fix(bpm-core-client): keep the local calendar day for zoned date picker values - #2
Merged
Merged
Conversation
…er values Calendar adapters emit zoned ISO strings — CalendarMethodsMoment returns moment(...).toISOString(), i.e. UTC. parseDatePickerValue split those on "T" and rebuilt the UTC calendar date as a local date, so every user east of UTC saw the picked day shift back by one, and the shifted value was persisted. Route zone-qualified input through new Date() so the runtime resolves the offset, and keep the manual parse for zone-less values. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BVBYyU83KfmAeJGj6gGsVm
coollugi
force-pushed
the
fix/date-picker-zoned-value
branch
from
August 3, 2026 12:23
29f2771 to
6fe126d
Compare
Contributor
Author
|
補充一下 base 的調整:這個 PR 已經從 原因是 也因為 如果你們的流程其實是要進 |
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
在表單的日期欄位選日期,UTC 以東的使用者會被存成前一天,而且被寫進簽核案件的就是這個位移過的值
在
Asia/Taipei重現:2026-08-192025-12-31datetime欄位也中招,只是比較不明顯 —— 存下的時刻是整個偏移一個 UTC offset(這裡是 8 小時),而不是差一天根因
CalendarMethodsMoment回傳的是帶時區的 ISO 字串,每一個操作最後都收在moment(...).toISOString(),也就是 UTC所以在
Asia/Taipei選 20 號,傳進parseDatePickerValue的是2026-08-19T16:00:00.000Z,這個值本身是正確的問題出在
parseDatePickerValue接著比對DATE_TIME_VALUE_PATTERN(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,這個 pattern 對結尾的Z照樣命中),用T切開之後,把 UTC 的日曆日期當成本地日期重建:等於拿 UTC 的那一頁日曆當成本地的日曆在用
修法
偵測時區後綴(
Z或±HH:MM),有的話就交給 runtime 自己解析 offset沒有時區的輸入維持原本的手動解析,所以
'2026-08-20'與'2026-08-20T09:30'仍然代表本地時間測試
新增
libs/bpm-core-client/src/lib/form/form-rendering.spec.ts,共 10 個案例涵蓋 UTC 輸入、UTC 兩側的帶 offset 輸入、無時區輸入的迴歸防護,以及
formatDatePickerValue與formatDateTimePickerValue兩者的無效輸入測試套件釘住
TZ=Asia/Taipei—— 這個 bug 在 UTC 的 runner 上看不見,不釘時區的測試不管有沒有 fix 都會過驗證過測試真的抓得到:只還原 source 的改動,其中 3 個會紅
nx test bpm-core-client(6 suites/22 tests)/nx lint bpm-core-client/nx typecheck bpm-core-client全部通過🤖 Generated with Claude Code
https://claude.ai/code/session_01BVBYyU83KfmAeJGj6gGsVm