diff --git a/resources/js/lib/changelog.ts b/resources/js/lib/changelog.ts index 4aa6d9636..3be6b60e7 100644 --- a/resources/js/lib/changelog.ts +++ b/resources/js/lib/changelog.ts @@ -43,11 +43,13 @@ export function changelogDays( timeZone: string, ): ChangelogDay[] { const days: ChangelogDay[] = []; + const calendar = new Intl.DateTimeFormat('en-CA', { timeZone }); for (const commit of commits) { - const date = new Date(commit.committed_at).toLocaleDateString('en-CA', { - timeZone, - }); + const parsed = new Date(commit.committed_at); + const date = Number.isNaN(parsed.getTime()) + ? 'Invalid Date' + : calendar.format(parsed); let day = days.at(-1); if (day?.date !== date) { diff --git a/tests/Unit/Changelog.test.ts b/tests/Unit/Changelog.test.ts index 23d33f856..448f4b2b1 100644 --- a/tests/Unit/Changelog.test.ts +++ b/tests/Unit/Changelog.test.ts @@ -94,3 +94,12 @@ void test('names the day relative to today in the reader’s time zone', () => { assert.deepEqual(changelogDayHeading('2026-10-14', 'Europe/Budapest', now), { title: 'Wednesday', date: 'Oct 14' }); assert.deepEqual(changelogDayHeading('2025-12-31', 'Europe/Budapest', now), { title: 'Wednesday', date: 'Dec 31, 2025' }); }); + +void test('keeps grouping when a commit has an invalid timestamp', () => { + const days = changelogDays( + [commit(1, 'not-a-date', 'alice'), commit(2, '2026-10-18T03:30:00Z', 'bob')], + 'Europe/Budapest', + ); + + assert.deepEqual(days.map((day) => day.date), ['Invalid Date', '2026-10-18']); +});