Repository navigation
fix: number dates before 1900-03-01 as Excel does, its 1900-02-29 included - #683
Merged
Merged
Conversation
| @@ -0,0 +1,119 @@ | |||
| /** | |||
| return typeof recorded.expect === "number" && typeof got === "number" ? Math.abs(got - recorded.expect) <= TOLERANCE : got === recorded.expect; | ||
| }; | ||
|
|
||
| describe("serials 0 to 61 against Excel's recorded answers", () => { |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
Local Codex review ledgerRound 1 (head before d4d74b3): three findings.
Round 2 (d4d74b3): LGTM. |
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
Dates before 1900-03-01 are now numbered as Excel numbers them, its fictitious 1900-02-29 included. This follows the decision on #661 and reverses c2ae160. Serial 1 is 1900-01-01, 59 is 1900-02-28, 60 is 1900-02-29 and 61 is 1900-03-01. From 61 on nothing changes.
The conversions now live in one pure module,
src/engine/serialCalendar.ts. It uses integer days-from-civil arithmetic and noDate, and every caller goes through it:The #650 conversion in the Excel download (
excelDateSerial) is gone, because the engine and the file now number alike. The plugin does not read .xlsx files, so there is no import side to change.Changed behaviour
DATE(1900,2,28)=59,DATE(1900,2,29)=DATE(1900,3,0)=60,DATE(1900,1,1)=1.DATEVALUE("1900-02-29")and typed1900-02-29are 60.YEAR/MONTH/DAY(0)are 1900 / 1 / 0, andTEXT(0,"yyyy/m/d")is1900/1/0.EOMONTH(DATE(1900,2,1),0)is 59. A result before 1900 is#NUM!(EOMONTH(0,-1)).DAYS360(,5)=5 andDAYS360(0.9999999,31)=30. This covers the coordinator's extra case from fix: an empty argument in a scalar place of a built-in function reads as Excel reads it #679, and the twoNOT_YETentries are removed.Tests changed because they pinned the old numbering
tests/engine/test_serialCalendar.ts: rewritten for the module. It is tested both ways over a wide range around the boundary, againstDate.UTC's real calendar from 61 on, and with generated dates and times (seed printed).tests/engine/test_dateUtils.ts:serialToDatewas removed.dateToSerialis pinned around the boundary and round-tripped withserialMoment.tests/engine/test_serialFromParts.ts: 1900-01-01 is 1; 59 / 60 / 61 are added.tests/engine/test_serialParts.ts:0.9999999is 1900-01-01.tests/engine/test_serialTimeZones.tsandtests/engine/test_weekNumbers.ts: these go through the module instead ofserialToDate.tests/vue/test_xlsxCells.ts: theexcelDateSerialblock was removed.tests/engine/test_emptyScalarArgument.ts: the DAYS360 serial-0NOT_YETentries were removed.New tests
tests/engine/fixtures/excel-1900-serials.jsonholds Excel's recorded answers (formulon goldens, en_US and ja_JP) for serials 0–61.tests/engine/test_excel1900Serials.tsruns them.Items to Confirm / Review
DATE(1900,1,60)=60. It follows from the recordedDATE(1900,3,0)=60 and from IronCalc's Excel1900 mode.EOMONTH(0,0)/(0,7)/(32,0)are recorded.date '1900-01-01') now use Excel numbering and acceptdate '1900-02-29'. A literal with a year below 100 used to fail becauseDate.UTCread it as 19xx; it is now read as written.COUPDAYS(1,DATE(1900,7,1),2,1)is 182), and so does this engine.DAYS360(60,60)is -1. This is the same rule that givesDAYS360(DATE(2011,2,28),DATE(2011,2,28))= -2.NOT_YET.coupdays_before_f2_b1, used to pass only because the real calendar happened to give Excel's answer; it now misses by the phantom day. The rest of that cluster fails before and after this change.Verification
yarn format && yarn lint && yarn build && yarn typecheck && yarn test && yarn test:engine && yarn test:fixtures && yarn quality, chained with&&.golden-check.tsover the en_US and ja_JP targets.coupdays_before_f2_b1, explained above.coupdays_before_f2_b1.27abdc2vs this head): three seeds, each overtests/engine/formulaGenerator.tsformulas plus a generator of date formulas, run once with serials spanning 0–130 and once with serials at or above 61.yarn devin Chrome (Playwright), with=DATE(1900,2,28)and=DATE(1900,3,1)formattedyyyy-mm-dd.1900-02-28and1900-03-01,=DATE(1900,2,29)shows1900-02-29 Wednesday, and the difference is 2.<v>59</v>,<v>61</v>and<v>60</v>, and openpyxl reads A1 and B1 as 1900-02-28 and 1900-03-01.User Prompt
Closes #661
work in GUIChatPluginSpreadsheet
🤖 Generated with Claude Code