package playevents import ( "testing" "time" ) func TestClampClientTime(t *testing.T) { created := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC) now := time.Date(2026, 11, 26, 12, 0, 0, 0, time.UTC) for _, c := range []struct { name string at time.Time expect time.Time }{ {"before the account existed", created.AddDate(-3, 0, 0), created}, {"an offline replay days old", now.AddDate(0, 0, -4), now.AddDate(0, 0, -4)}, {"a clock a little fast", now.Add(4 * time.Minute), now.Add(4 * time.Minute)}, {"a clock years ahead", now.AddDate(5, 0, 0), now}, } { if got := ClampClientTime(c.at, created, now); !got.Equal(c.expect) { t.Errorf("%s: got %v, want %v", c.name, got, c.expect) } } }