[codex] fix historical timezone endOf regression#3040
Open
susiwen8 wants to merge 2 commits intoiamkun:devfrom
Open
[codex] fix historical timezone endOf regression#3040susiwen8 wants to merge 2 commits intoiamkun:devfrom
susiwen8 wants to merge 2 commits intoiamkun:devfrom
Conversation
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.
Summary
endOf()boundary calculations to derive the last instant from the next unit boundary instead of constructing local23:59:59.999Asia/Singapore/Asia/Kuala_LumpurTZ=Asia/Singaporein the test script so the bug stays covered in CIRoot Cause
daysInMonth()relies onendOf('month').date(). For1981-12-01in Singapore and Kuala Lumpur, constructing the local month end as1981-12-31 23:59:59.999crosses the midnight offset jump toUTC+08:00, so the nativeDatenormalizes to1982-01-01 00:29:59and the day becomes1.This patch follows Moment's approach and computes
endOf(...)asstartOf(nextUnit) - 1ms, which preserves the correct local last day even when midnight itself has a historical offset change.Validation
TZ=Asia/Singapore npm run test-issue3003TZ=Asia/Kuala_Lumpur npx jest test/issues/issue3003.test.js --runInBand --coverage=falsenpx jest test/display.test.js test/manipulate.test.js --runInBand --coverage=falsenpx jest test/plugin/badMutable.test.js --runInBand --coverage=falsenpx jest test/plugin/timezone.test.js --runInBand --coverage=false -t "startOf and endOf"TZ=Asia/Singapore npm run test-tznpx eslint src/index.js test/issues/issue3003.test.jsnpm testruns with 94/94 suites and 776/776 tests passing, but currently exits non-zero because the repository's global coverage threshold still reportslines 99.95% < 100%