package calendartest import ( "context" "net/http" "net/url" "strconv" "strings" "testing" "time" ) // TestTheSharePageSaysFeedTimesInTheViewersZone: the database hands every // stored time back in UTC (rastrillo's _timezone=UTC, from fb806a2), and // the share page used to print a feed's created and last-polled times // straight off the row — UTC, without saying so. They are the viewer's // zone now, like every other time on every other page. func TestTheSharePageSaysFeedTimesInTheViewersZone(t *testing.T) { app, session := signedIn(t, "someone@example.com") h := app.Handler() if rec := postAs(t, h, session, "/settings", url.Values{"zone": {"Pacific/Auckland"}, "week_start": {"1"}, "default_reminder_min": {"10"}, "default_all_day_min": {"0"}}); rec.Code != http.StatusSeeOther { t.Fatalf("POST /settings = %d", rec.Code) } person := app.PersonByAddressForTest(t, "someone@example.com") cal, err := app.StoreForTest().DefaultCalendarID(context.Background(), person.ID) if err != nil { t.Fatal(err) } share := "/calendars/" + strconv.FormatInt(cal, 10) + "/share" if rec := postAs(t, h, session, "/calendars/"+strconv.FormatInt(cal, 10)+"/feeds", nil); rec.Code != http.StatusSeeOther { t.Fatalf("mint feed = %d", rec.Code) } // 20:00 UTC on 2 March is 09:00 on 3 March in Auckland (NZDT, +13). at := time.Date(2026, 3, 2, 20, 0, 0, 0, time.UTC) if _, err := app.DBForTest().Exec(`UPDATE feeds SET created_at = ?, last_polled_at = ?, poll_count = 1`, at, at); err != nil { t.Fatal(err) } page := getAs(t, h, session, share).Body.String() for _, want := range []string{"Created 3 March 2026", "last 3 Mar 09:00"} { if !strings.Contains(page, want) { t.Errorf("share page lacks %q (the viewer's zone):\n%s", want, page) } } }