"""The weekly report's hour is kept in the zone of whoever saved it, and a reader sees it on their own clock (#5378).""" from datetime import datetime, timezone from zoneinfo import ZoneInfo from steward.core.reports import report_due, schedule_in NY = ZoneInfo("America/New_York") BERLIN = ZoneInfo("Europe/Berlin") def test_sunday_eight_in_new_york_is_due_at_noon_utc_in_october(): sunday_noon_utc = datetime(2026, 10, 11, 12, 30, tzinfo=timezone.utc) # 08:30 EDT assert report_due(sunday_noon_utc, 6, 8, NY) assert not report_due(sunday_noon_utc, 6, 8, timezone.utc) assert not report_due(datetime(2026, 10, 11, 8, 30, tzinfo=timezone.utc), 6, 8, NY) def test_a_reader_sees_the_saved_hour_on_their_own_clock(): now = datetime(2026, 10, 8, 15, 0, tzinfo=timezone.utc) assert schedule_in(6, 8, NY, NY, now) == (6, 8) assert schedule_in(6, 8, NY, BERLIN, now) == (6, 14) assert schedule_in(6, 8, timezone.utc, NY, now) == (6, 4) # an old UTC schedule, read in New York assert schedule_in(0, 1, timezone.utc, NY, now) == (6, 21) # Monday 01:00 UTC is Sunday evening there def test_what_a_reader_picks_and_saves_is_what_they_see_again(): now = datetime(2026, 10, 8, 15, 0, tzinfo=timezone.utc) for day in range(7): for hour in (0, 8, 23): assert schedule_in(day, hour, BERLIN, BERLIN, now) == (day, hour)