BOLT-1267 P1 — fix Bugbot round 4 UTC/local time mismatch on PR #12218
completedAgent: richie-engineer
Priority: 1
Cursor Bugbot landed a NEW Medium finding on PR #12218 at 01:23 UTC (4 min after the R3 fix push 717a8e142b):
**UTC dates, local times mismatch**
`calendarDayOffset` is derived from UTC calendar dates via `toISOString()`, while segment times use browser-local `getHours()` / `getMinutes()` (same as `parseTimeFromISO` elsewhere). In western timezones, chronologically later batches can share a UTC day with earlier ones, so `buildSegments` places later actions left of earlier ones and stretches gaps incorrectly on the preview chart.
**Locations:**
- apps/dashboard/packs/programs/routes/(programs)/events/[id]/edit/_lib/batchesToActionConfigs.ts#L7-L36
- apps/dashboard/packs/programs/routes/(programs)/events/_components/EventCurvePreview.tsx#L72-L88
**Validity:** legit. The R3 fix added calendarDayOffset derived from UTC, but the rest of the code uses local time. In western timezones (Pacific especially — Richie is ET so this matters for any user west of him too), a batch scheduled at 11pm ET on Mon becomes 04:00 UTC Tue, so its UTC calendar day is Tue but its local clock-day is Mon. If another batch on Tue 6pm ET (23:00 UTC Tue) follows, both share UTC day Tue but the chronologically-later batch is now the same day-offset as the earlier one — gap collapses, ordering can flip.
**Fix direction:** derive `calendarDayOffset` from LOCAL date components (year/month/day from `new Date(iso).getFullYear()/getMonth()/getDate()`), NOT from `toISOString()`. Both endpoints (startAt + endAt) must use the same local-date basis.
**Tests:** add buildSegments cases for batches across western-timezone day boundaries. Specifically: a Mon 11pm ET batch followed by a Tue 6pm ET batch must render with day-offset 0 and 1, not both 1. Use a fixed timezone in tests (mock Date or use Intl).
**Worktree:** /home/agent/workspaces/bolt-1267 (already exists, currently on commit 717a8e142b).
**Branch:** winston/bolt-1267-event-curve-preview-phase-1.
**PR:** https://github.com/TextureHQ/mono/pull/12218
**Last commit:** 717a8e142b.
Run local checks per POST-PUSH-PROTOCOL before pushing. Resolve cursor thread with SHA reply on push. Bugbot bug id: f4174dcf-4e45-43b6-aefe-f56eb8edda26.
Event Timeline
created
status_change
queued → in_progress
subagent_spawned
spawn claim: bugbot-r4-utc-local-tz-mismatch
failed
lease expired — re-queued for retry
in_progress → queued
progress
R4 Bugbot fix pushed: commit 8e1d8eef6d. Replaced UTC-based calendarDayOffset derivation with local-date getLocalCalendarDayIndex(). 18/18 tests pass. Bugbot thread replied. CI watching.
subagent_completed
subagent done: Bugbot R4 fixed; commit 8e1d8eef6d; 18/18 tests; CI kicked
status_change
queued → in_progress
status_change
in_progress → blocked
status_change
blocked → completed