Skip to content

california-clock-change generates the wrong date for months that start on a Sunday #247

@joyalicegu

Description

@joyalicegu

The code for calculating the second Sunday in March doesn't work this year (2026) because March starts with a Sunday.

                // Second Sunday in March
                const springForward = new Date(y, 2, 1 + (14 - new Date(y, 2, 1).getDay()));

Should probably be something like:

                // Second Sunday in March
                let firstDayInMarchDay = new Date(y, 2, 1).getDay();
                let firstSundayInMarchDay = 1 + (7 - firstDayInMarchDay) % 7;
                let secondSundayInMarchDay = firstSundayInMarchDay + 7;
                const springForward = new Date(y, 2, secondSundayInMarchDay);

There's also a similar bug for November, which only is an issue when November 1st is a Sunday (also happens in 2026).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions