Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(timeline): accept citation dates in years 0001-0099
masashiono06116b6feb42b257
diff --git a/src/core/timeline-citations.ts b/src/core/timeline-citations.tsindex d9cb07e740..e4434b3218 100644--- a/src/core/timeline-citations.ts+++ b/src/core/timeline-citations.ts@@ -83,6 +83,6 @@ function isValidDate(s: string): boolean {const [y, mo, d] = s.split('-').map(Number);if (mo < 1 || mo > 12) return false;if (d < 1 || d > 31) return false;- const dt = new Date(Date.UTC(y, mo - 1, d));+ const dt = new Date(new Date(0).setUTCFullYear(y, mo - 1, d)); // not Date.UTC: it maps years 0-99 to 1900-1999return dt.getUTCFullYear() === y && dt.getUTCMonth() === mo - 1 && dt.getUTCDate() === d;}diff --git a/test/timeline-parser-regression.test.ts b/test/timeline-parser-regression.test.tsindex 7320d5bae1..7f7ce3e179 100644--- a/test/timeline-parser-regression.test.ts+++ b/test/timeline-parser-regression.test.ts@@ -166,6 +166,18 @@ test('fence masking preserves mixed LF, CRLF, and bare CR at exact offsets', ()// Gmail URL, so the citation text strip must take the target with it — the// leftover `(url)` otherwise became the summary itself, and timeline rows// cannot be removed once written.+describe('inline citation timeline dates', () => {+ test('a citation dated in years 0001-0099 is kept', () => {+ expect(parseInlineCitationTimelineEntries('Event happened. [Source: chronicle, 0099-01-01]\n')).toEqual([+ { date: '0099-01-01', source: 'chronicle', summary: 'Event happened.' },+ ]);+ });++ test('a calendar-invalid citation date is still dropped', () => {+ expect(parseInlineCitationTimelineEntries('Event happened. [Source: chronicle, 2026-02-30]\n')).toEqual([]);+ });+});+describe('inline citation link targets (#5483)', () => {const cite = emailCitation({account: '[email protected]',