Fix DST date calculation when 1st of month is Sunday, add tests#251
Fix DST date calculation when 1st of month is Sunday, add tests#251
Conversation
The formula for computing the second Sunday in March and first Sunday in November produced wrong dates when the 1st of the month fell on a Sunday (getDay() returns 0). For 2026, this meant showing March 15 instead of March 8, and would have shown November 8 instead of November 1. Fix by treating Sunday as day 7 in the calculation. Add inline automated tests (20 assertions across 5 years) in a collapsed details/summary element that auto-opens on failure. https://claude.ai/code/session_01DgKd487wLpi8VkHyWSXWTX
|
Claude finished @simonw's task —— View job Code Review Results ✅Summary: This is a well-crafted fix for a subtle DST calculation bug with comprehensive test coverage. The implementation is solid and the tests provide excellent protection against regressions. ✅ Excellent Bug FixThe core issue was elegantly solved in // OLD: const marchDay = new Date(y, 2, 1).getDay();
// NEW: const marchDay = new Date(y, 2, 1).getDay() || 7;Why this works: ✅ Comprehensive Test CoverageThe test suite (
✅ Code Quality
✅ Performance & Security
🔍 Minor Observations
Recommendation: ✅ APPROVEThis PR demonstrates excellent software engineering practices:
The fix is mathematically sound and the tests provide strong confidence in the solution. |
Deploying tools with
|
| Latest commit: |
202582d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e538707f.tools-b1q.pages.dev |
| Branch Preview URL: | https://claude-fix-california-clock-4s11.tools-b1q.pages.dev |
|
Tests are now grouped by year with separator headers, show the full friendly date (e.g. "Sunday Mar 8, 2026") alongside the ISO date assertion, and annotate the 2026 edge case where the 1st of the month is a Sunday. Summary line now includes total count. https://claude.ai/code/session_01DgKd487wLpi8VkHyWSXWTX
|
Claude finished @simonw's task —— View job Code Review Complete ✅Todo List:
SummaryThis is an excellent PR that demonstrates careful engineering and attention to detail. The DST calculation bug fix is mathematically sound, and the test suite provides comprehensive coverage with clear, informative output. The code quality is high throughout. ✅ Bug Fix - Excellent ImplementationCore Issue (Lines 157, 160): // Fixed: const marchDay = new Date(y, 2, 1).getDay() || 7;
// Fixed: const novDay = new Date(y, 10, 1).getDay() || 7;Why this fix works perfectly:
✅ Test Coverage - Comprehensive and InformativeTest Suite Strengths (Lines 302-383):
Addressing "Make test results more informative":
✅ Code QualityStrengths:
Best Practices Followed:
✅ PerformanceExcellent Performance Characteristics:
✅ SecurityNo Security Concerns:
✅ Browser CompatibilityModern API Usage (All well-supported):
🔍 Minor Observations
Recommendation: ✅ APPROVEThis PR demonstrates exceptional software engineering practices:
The test informativeness is already excellent - they provide clear summaries, detailed failure information, group results logically, and auto-expand only when needed. The implementation successfully addresses the original request while maintaining high code quality standards. |
The formula for computing the second Sunday in March and first Sunday
in November produced wrong dates when the 1st of the month fell on a
Sunday (getDay() returns 0). For 2026, this meant showing March 15
instead of March 8, and would have shown November 8 instead of
November 1. Fix by treating Sunday as day 7 in the calculation.
Add inline automated tests (20 assertions across 5 years) in a
collapsed details/summary element that auto-opens on failure.
https://claude.ai/code/session_01DgKd487wLpi8VkHyWSXWTX