Repository navigation
Conversation
With `dateSpanLarge`, `format('dddd', -7, { leap1900: false })` gave an empty string, and `format('dddd', -0.25, { leap1900: false })` gave `Saturday` for a time on Friday 29 December 1899.
The weekday was the remainder of the truncated serial. For a negative serial that remainder is negative, so the lookup in the list of names found nothing, and a serial with a time truncates to the day after the one `toYMD` gets.
The weekday is now taken from the day passed to `toYMD`, with a remainder that is never negative. Dates from day 0 on are unchanged.
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.
A date before day 0 (a negative serial) gets no weekday name, or the name of the day after.
Expected:
Saturday,1512-03-15 Fridayand1899-12-29 18:00 Friday. Excel has no dates before 1900, so the reference here is Google Sheets, where=TEXT(-141639,"dddd")isFridayand=TEXT(-141500,"yyyy-mm-dd dddd")is1512-08-01 Thursday. The day, month and year are already right; only the name is wrong.The cause is in
runPartinsrc/runPart.ts: the weekday is(6 + date) % 7, wheredateis the truncated serial. For a negative serial that remainder is negative, so the lookup in the list of names finds nothing. And a negative serial with a time truncates to the day after the onetoYMDgets, so the name is one day ahead.The change takes the weekday from the same day that is passed to
toYMD, and keeps the remainder from going negative. Dates from day 0 on are unchanged.Tests: one new test in
test/datebounds.spec.tswith eight cases, two of them the Google Sheets rows above. It fails onmasterand passes with the change.npm test,npm run test-all,npm run lintandnpm run typecheckpass.I found this with the help of Claude Fable (an AI model), which also drafted the fix. I have reviewed and tested the change myself and take responsibility for it. Happy to adjust anything.