Repository navigation
[TS] Compute Date time fields without calendar decomposition - #533
Merged
Merged
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.
Date time-component getters rebuilt the complete calendar and allocated DateParts objects for values that only depend on the timestamp within a second/minute/hour/day or on the weekday. Compute getDay/getHours/getMinutes/getSeconds/getMilliseconds directly with the existing remainder/floor arithmetic. UTC wrappers keep calling these shared implementations; no supported input bound or existing UTC-for-local environment assumption changes.
For the identical ordinary TypeScript program reading five UTC fields at -1 ms, interpreter instructions decrease from 1,836 to 338, with calendar instructions decreasing from 745 to 0. This is a narrow execution-cost comparison, not a 200-class coverage claim.
Validation: 25 focused Date source-model tests passed, including TimeClip min/max, negative/fractional input, invalid Date and Node replay of the original source. The native comparison script now checks 10,139 timestamp cases (seeded complete clipped range plus unit boundaries, signed zero, NaN and infinities) against JavaScript UTC getters; all pass. The same boundary semantics regression passes unchanged main, while the calendar-traversal regression fails there as intended. Strict usvm-ts detektMain/detektTest passed. Full suites left to CI.