From f47c4ecd54e7c17db5cc227edcc4b0774419e03d Mon Sep 17 00:00:00 2001 From: martbost Date: Wed, 14 Oct 2026 17:08:05 -0500 Subject: [PATCH] Rotator: shared Central-day formatter in summary (toLocaleDateString with timeZone built a formatter per hit; the status strip took ~4 s) Co-Authored-By: Claude Opus 5.5 --- rotator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rotator.js b/rotator.js index 00d79fd..870d4e3 100644 --- a/rotator.js +++ b/rotator.js @@ -206,7 +206,9 @@ async function sourceCounts(owner, days) { } // a source was deleted: its links go back to having none async function detachSource(owner, sid) { let n = 0; for (const r of J.db.rotations) if (r.owner === norm(owner) && r.sourceId === String(sid)) { delete r.sourceId; n++; } if (n) J.save(); return n; } -const ctDay = ts => new Date(ts).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); +// shared formatter: toLocaleDateString(..., {timeZone}) builds a new Intl formatter per call (slow per hit; 2026-10-14) +const CT_DAY_FMT = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' }); +const ctDay = ts => CT_DAY_FMT.format(new Date(ts)); // one view across everything a member owns, for Reports async function summary(owner, days) { const mine = J.db.rotations.filter(r => r.owner === norm(owner)); const ids = new Set(mine.map(r => r.id));