Documentation
¶
Overview ¶
Package timefilter parses the ?from and ?to query parameters, and named variants such as ?date_from and ?date_to, for the operator-facing list and export endpoints. Every endpoint shares one contract, so an operator who learns one endpoint can use the next one the same way.
It accepts two formats:
- RFC3339 instants, such as "2026-01-01T00:00:00Z". The dashboard sends these, derived from the start and end of day in the tenant's time zone (ADR-010).
- Bare YYYY-MM-DD dates, such as "2026-01-01". These are convenient for curl and CLI users running ad-hoc queries.
A date-only value is anchored at UTC. `from` becomes 00:00:00Z, the start of the day. `to` becomes 23:59:59.999999Z, the last microsecond of the day, so the day named in `to` is included. That matches what an operator typing "from=2026-01-01&to=2026-01-31" expects.
The end is the last microsecond, not the last second. Postgres timestamptz keeps microseconds, so a 23:59:59Z bound would drop every row stamped 23:59:59.000001 to .999999. It is not .999999999 either, because Postgres cannot hold nanoseconds. Whether such a value is truncated or rounded up to the next day's 00:00:00 depends on how it reaches the server.
Consumers do not all compare `to` the same way:
- Inclusive (`<= to`): the invoice list and invoices.csv, customers.csv, subscriptions.csv, usage-events.csv, the audit log and audit-log.csv.
- Exclusive (`< to`): the usage event list and aggregate (/v1/usage-events, /v1/usage-events/aggregate), all through usage.buildUsageWhere, and customer usage (/v1/customers/{id}/usage, through usage.AggregateClaims).
For a date-only `to`, both read the same in practice. The exclusive consumers miss only a row stamped at exactly 23:59:59.999999.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRange ¶
ParseRange reads two named query parameters from the request and returns their parsed time.Time values. A missing parameter returns the zero time, and callers branch on IsZero to skip that side of the filter.
It returns errs.Invalid on malformed input. The handler should pass that to respond.FromError, which answers 422 validation_error naming the parameter. It also refuses an inverted range (`to` before `from`). Equal endpoints are allowed (see below).
fromParam and toParam are usually "from" and "to", but the audit log uses the legacy names "date_from" and "date_to". Pass the names the endpoint already exposes. This helper does not normalize the names, because that would change a URL contract that operators see.
Types ¶
This section is empty.