Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions resources/js/lib/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Unit/Changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});