feat(provenance): locale-independent formatPostDate util

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 20:15:23 -04:00
parent f6d5353b3b
commit 63a7cbdde4
2 changed files with 30 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// Locale-independent post-date formatting. Uses a fixed month table and
// UTC getters so the rendered string never varies by browser/CI locale
// or timezone (toLocaleDateString would make tests flaky).
const MONTHS = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]
export function formatPostDate(iso) {
if (!iso) return null
const d = new Date(iso)
if (isNaN(d.getTime())) return null
return `${MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`
}