yera.ui.utils
Utility functions for the local UI server.
Symbols
fmt_relative
fmt_relative(
t: datetime,
now: datetime | None = None,
) → strFormats a timestamp as a compact relative label for session rows.
Buckets match the sidebar design: minutes within the last hour, hours
within the last day, a lowercase weekday within the last week, then an
abbreviated mon d date. Names come from fixed English tables so output
is stable regardless of the server's locale.
Parameters
t
type: datetime
Timestamp to format. Coerced to UTC if naive (see below).
now
type: datetime | None = None
Reference time, for testing. Defaults to datetime.now(UTC).
Returns
type: str
A lowercase relative-time string such as "5m ago", "2h ago", "tue", or "jun 30".