test(time): fix roundTime_locale DST failure in time.test.ts#21539
Open
davesecops wants to merge 1 commit intoapache:masterfrom
Open
test(time): fix roundTime_locale DST failure in time.test.ts#21539davesecops wants to merge 1 commit intoapache:masterfrom
davesecops wants to merge 1 commit intoapache:masterfrom
Conversation
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Fixes the
roundTime_localetest intest/ut/spec/util/time.test.tswhich fails in any DST-observing timezone (~70% of world timezones).Fixed issues
Details
Before: What was the problem?
The
getISOTimezone()helper computed the UTC offset fromnew Date(0)(January 1, 1970) and applied that fixed offset string to construct expected dates across different months (January and October 1986):In DST-observing timezones the offset in January differs from October. For example, US Eastern: January = UTC-5 (EST), October = UTC-4 (EDT). The test constructs "midnight EST" for an October date, but
roundTime()correctly rounds to midnight EDT — producing a 1-hour mismatch.This affects any developer running
npm run testin a DST-observing timezone (US, EU, Australia, NZ, Brazil, etc.).After: How does it behave after the fixing?
Replaced ISO string construction with the
Dateconstructor using numeric arguments:The
Dateconstructor with numeric arguments always interprets them in the machine's local timezone, automatically using the correct offset for each specific date (including DST transitions). This is exactly whatroundTime(..., false)computes — local time boundaries — so the expected and actual values always agree regardless of timezone.The
getISOTimezone()helper is removed as it has no other callers in the codebase.Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
The fix is to the test itself. Full test suite passes (24/24 suites, 189/189 tests) after this change.
Merging options
Other information
This is a test-only change — no production code modified. The fix is 8 lines added, 20 lines removed (simpler code that works in all timezones).