fix(transpiler): YEAR/MONTH/DAY use UTC serial math (local-time getters read dates a day early west of UTC)#64
Merged
Conversation
…ers read dates a day early west of UTC The emitted lowerings called new Date((s-25569)*86400000).getMonth()/ getDate()/getFullYear() — LOCAL-time getters — so any engine runtime west of UTC read every Excel serial one day early (DAY(Jun-30-2023)=29). The DATE(YEAR(x),MONTH(x),DAY(x)) reconstruction idiom (live on A-1 Valuation!G7) rebuilt dates one serial low, shifting date-keyed COUNTIFS/SUMIFS windows and flipping comparison flags across whole sheets; the engine's results depended on the machine timezone. YEAR/MONTH/DAY now route through _serialToYMD (pure-integer UTC math, 1900-epoch-quirk aware); _serialToYMD added to the sheet-module helper imports. New TZ-pinned child-process cases in test-date-axis-sumifs.mjs run the engine under America/Denver and Pacific/Auckland with a hazard probe as negative control — RED pre-fix with exactly the A-1-observed values (DAY=29, rebuilt serial 45106), 26/26 GREEN post-fix. Full npm test + cargo test green. Found by the all-17-sheet warm-GT sweep on the post-#62 A-1 rebuild: the residual numeric divergences (Technology 284k, PP&E 84k, Lease Am 9k, Debt 7.4k, WC 5.9k, Valuation 7) all carry the one-day-shift signature. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 10, 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.
Found by running the all-17-sheet warm-GT sweep on the post-#62 A-1 rebuild: 9/17 sheets came back numerically EXACT, and the residual divergences (Technology 284k, Owned Asset PP&E 84k, Lease Amortization 9k, Debt 7.4k, Working Capital 5.9k, Valuation 7) all carried a one-day-shift signature —
Valuation!G7GT=45107 (Jun 30 2023) vs got=45106, integer counts off by one, 0/1 flags flipped.Root: the
YEAR/MONTH/DAYlowerings usednew Date((s-25569)*86400000).getMonth()/.getDate()/.getFullYear()— local-time getters — so any engine runtime west of UTC reads every Excel serial one day early. TheDATE(YEAR(x),MONTH(x),DAY(x))reconstruction idiom rebuilds dates one serial low and every date-keyedCOUNTIFS/SUMIFSwindow downstream shifts by a day. The engine's output depended on the machine's timezone.Fix: route all three through the existing
_serialToYMDhelper (pure-integer UTC math, 1900-epoch-quirk aware); add it to the sheet-module helper imports.Test: new TZ-pinned child-process cases in
test-date-axis-sumifs.mjs— the engine runs underTZ=America/DenverandTZ=Pacific/Auckland, with a hazard probe (oldDay === 29) as the negative control so the case provably discriminates on any CI machine including UTC runners. RED pre-fix with exactly the A-1-observed values (DAY=29, rebuilt=45106); 26/26 GREEN post-fix. Fullnpm test+cargo testgreen.A-1 rebuilt with the fixed parser; the before/after warm-GT sweep result will be posted to #33.
🤖 Generated with Claude Code