Commit 584aa0f
fix(core): use isSame() in isSameMonth to include year comparison (#1579)
* fix(core): use isSame() in isSameMonth to include year comparison
Previously, isSameMonth() compared only the month number using format('M'),
causing it to return true for dates in the same month but different years
(e.g. Jan 2024 vs Jan 2025).
Replace with dayjs .isSame(date, 'month') which checks both month and year.
Add unit tests covering same month/year, cross-year, different months,
year boundary, and ISO datetime string cases.
Fixes #1578
* fix(core): parse isSameMonth dates in UTC to avoid timezone shifts
Use dayjs.utc() instead of dayjs() to ensure consistent month comparison
regardless of the runtime's local timezone. Without UTC normalization,
ISO strings with Z suffix could shift to the previous month in
negative-offset environments.
Addresses review feedback.
* chore: remove redundant isSameMonth tests
The isSameMonth function tests are already covered by existing test infrastructure.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: inline isSameMonth logic and remove utility
The dayjs.utc().isSame() call is only used in one place, so inline it
directly rather than maintaining a separate utility function.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Tyler Dane <tyler@switchback.tech>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 189fcd0 commit 584aa0f
2 files changed
Lines changed: 2 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | 66 | | |
81 | 67 | | |
82 | 68 | | |
| |||
0 commit comments