Skip to content

Preserve the calendar date when scand matches weekday names - #22364

Open
NUAAwqy wants to merge 3 commits into
mozilla:masterfrom
NUAAwqy:fix-scand-weekday-date
Open

NUAAwqy wants to merge 3 commits into
mozilla:masterfrom
NUAAwqy:fix-scand-weekday-date

Conversation

@NUAAwqy

@NUAAwqy NUAAwqy commented Oct 28, 2026 •

Copy link
Copy Markdown

util.scand() overwrote the day of the month with the index of the matched weekday name: for ddd/dddd it did data.day = days.indexOf(value), i.e. a value in 0..6. So scand("yyyy-mm-dd ddd", "2026-10-25 Sun") produced a date at the end of September instead of 2026-10-25, and any format containing a weekday name was broken.

A weekday name doesn't say anything about the day of the month, so those two handlers now just consume the token.

Keep ddd and dddd from overwriting the calendar date and cover printd/scand round trips for every weekday in either token order.

@Snuffleupagus Snuffleupagus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please stop posting walls of fully AI generated text when opening PRs.

Comment thread test/unit/scripting_spec.js Outdated
Comment on lines +1401 to +1407
for (const format of [
"yyyy-mm-dd ddd",
"yyyy-mm-dd dddd",
"ddd yyyy-mm-dd",
"dddd yyyy-mm-dd",
]) {
it(`should preserve the day of the month in ${format}`, async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generating test-cases within loops is not a good pattern to use, despite what your AI might "think".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, that made the cases unreadable. Rewritten as six plain calls with one literal expected array; the loop is gone.

Generating the expectations in a loop hides which format/value pair a
failure refers to, so list the six calls and the one result array.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants