parseRFC3339Filter parses an optional RFC3339 timestamp query param into a time, returning a 400 envelope on a malformed value.
(raw, name string)
| 662 | // parseRFC3339Filter parses an optional RFC3339 timestamp query param into |
| 663 | // a time, returning a 400 envelope on a malformed value. |
| 664 | func parseRFC3339Filter(raw, name string) (time.Time, error) { |
| 665 | raw = strings.TrimSpace(raw) |
| 666 | if raw == "" { |
| 667 | return time.Time{}, nil |
| 668 | } |
| 669 | t, err := time.Parse(time.RFC3339, raw) |
| 670 | if err != nil { |
| 671 | return time.Time{}, NewError(http.StatusBadRequest, "invalid_filter", |
| 672 | name+" must be RFC3339 (e.g. 2026-05-25T00:00:00Z)") |
| 673 | } |
| 674 | return t, nil |
| 675 | } |
| 676 | |
| 677 | func rfc3339OrEmpty(t time.Time) string { |
| 678 | if t.IsZero() { |
no test coverage detected