timefilter

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package timefilter is the shared parser for ?from / ?to (and named variants like ?date_from / ?date_to) query parameters across operator-facing list and export endpoints. One contract everywhere so an operator who learns one endpoint doesn't trip on the next.

Accepts two formats:

  • RFC3339 instants: "2026-01-01T00:00:00Z" — what the dashboard sends, derived from tenant-TZ start/end-of-day per ADR-010.
  • Bare YYYY-MM-DD dates: "2026-01-01" — convenient for curl/CLI users running ad-hoc queries.

Date-only inputs are anchored at UTC: `from` becomes 00:00:00Z (start of day), `to` becomes 23:59:59Z (end of day) so a YYYY-MM-DD range is inclusive on both ends — matches what an operator typing "from=2026-01-01&to=2026-01-31" intuitively expects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRange

func ParseRange(r *http.Request, fromParam, toParam string) (from, to time.Time, err error)

ParseRange reads two named query params from the request and returns their parsed time.Time values. Missing params return zero-value times (callers branch on IsZero to skip the filter).

Returns errs.Invalid on malformed input — the handler should pipe through respond.FromError to surface a 400. Also enforces that `to` (when both set) lands strictly after `from`.

fromParam and toParam are usually "from"/"to" but the audit log uses the legacy "date_from"/"date_to" naming. Pass whichever the endpoint has historically exposed; this helper doesn't normalize the param names because that would be an operator-visible URL contract change.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL