fix(metadata): preserve calendar dates across timezones

Keep month-name metadata dates stable in positive UTC offsets so local-to-UTC conversion cannot change the stored calendar day.

Fixes #1194
This commit is contained in:
neon
2026-08-30 04:27:13 +00:00
parent 3561d5ddd6
commit 661b265251
2 changed files with 3 additions and 1 deletions
@@ -28,6 +28,7 @@ describe('published-date utils', () => {
expect(parsePublishedDateKey('1965/8/1')).toBe('1965-08-01');
expect(parsePublishedDateKey('1965-08-01T12:30:00Z')).toBe('1965-08-01');
expect(parsePublishedDateKey('August 1, 1965')).toBe('1965-08-01');
expect(parsePublishedDateKey('January 1, 2020')).toBe('2020-01-01');
expect(parsePublishedDateKey('1965')).toBeUndefined();
});
@@ -60,7 +60,8 @@ export function parsePublishedDateKey(value: unknown): string | undefined {
if (MONTH_NAME_RE.test(trimmed) && /\b\d{1,2}\b/.test(trimmed) && /\b\d{4}\b/.test(trimmed)) {
const parsed = new Date(trimmed);
return dateToPublishedDateKey(parsed);
if (Number.isNaN(parsed.getTime())) return undefined;
return buildDateKey(String(parsed.getFullYear()), String(parsed.getMonth() + 1), String(parsed.getDate()));
}
return undefined;