From 5264453baab2b5810a98a49040cf18d771e13f23 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 13 Jul 2026 18:17:25 +0000 Subject: fix(web): account for Google Calendar's exclusive all-day end-date A single-day all-day event's End.Date is one calendar day past its own day (Google Calendar convention, already documented by TestParseEventTime_AllDayEvent). isMultiDayEvent/multiDayVariant didn't adjust for this, so every all-day event -- including single-day ones -- was misclassified as multi-day and duplicated across Today and Tomorrow. --- internal/handlers/timeline_multiday_test.go | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'internal/handlers/timeline_multiday_test.go') diff --git a/internal/handlers/timeline_multiday_test.go b/internal/handlers/timeline_multiday_test.go index 3dc2005..7af2cbe 100644 --- a/internal/handlers/timeline_multiday_test.go +++ b/internal/handlers/timeline_multiday_test.go @@ -81,3 +81,49 @@ func TestMultiDayVariant_DayOutsideSpan_ReturnsEmpty(t *testing.T) { t.Errorf("variant = %q, want empty", got) } } + +func TestIsMultiDayEvent_SingleDayAllDayEvent_False(t *testing.T) { + // Exclusive end-date convention: a single-day all-day event on July 13 + // has Start=Jul13 00:00, End=Jul14 00:00 (one day past its own day). + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-14T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-1", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + if isMultiDayEvent(item) { + t.Error("expected a single-day all-day event (exclusive end-date) to not be multi-day") + } +} + +func TestIsMultiDayEvent_MultiDayAllDayEvent_True(t *testing.T) { + // A 3-day all-day event (Jul 13, 14, 15) has End=Jul16 00:00 (exclusive). + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-2", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + if !isMultiDayEvent(item) { + t.Error("expected a 3-day all-day event to be multi-day") + } +} + +func TestMultiDayVariant_MultiDayAllDayEvent_LastRealDayIsEnds(t *testing.T) { + // The 3-day all-day event above (Jul 13-15 inclusive, End=Jul16 exclusive) + // must report "ends" on Jul 15 (its real last day), not Jul 16. + start, _ := time.Parse(time.RFC3339, "2026-07-13T00:00:00Z") + end, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + item := models.TimelineItem{ + ID: "allday-2", Type: models.TimelineItemTypeEvent, + Time: start, EndTime: &end, IsAllDay: true, + } + renderDay, _ := time.Parse(time.RFC3339, "2026-07-15T00:00:00Z") + if got := multiDayVariant(item, renderDay); got != "ends" { + t.Errorf("variant on last real day = %q, want %q", got, "ends") + } + exclusiveEndDay, _ := time.Parse(time.RFC3339, "2026-07-16T00:00:00Z") + if got := multiDayVariant(item, exclusiveEndDay); got != "" { + t.Errorf("variant on the exclusive (non-real) end day = %q, want empty", got) + } +} -- cgit v1.2.3