Skip to main content

usage_window

Function usage_window 

Source
pub fn usage_window(
    q: &UsageQuery,
    now: DateTime<Utc>,
) -> Result<(String, String), String>
Expand description

Resolve a usage query into the [since, until) bounds the store is asked for.

The store compares event timestamps to these bounds as strings, so this is where the window is made safe to compare (#255):

  • both bounds are parsed, so a value that is not a timestamp is rejected instead of selecting whatever it happens to sort between;
  • both are re-rendered with to_rfc3339(), the spelling events are stamped with. Any other spelling mis-sorts at the edge — a Z suffix sorts after the . of a fractional second, so an event half a second into the window compared as before it;
  • days is bounded before it reaches date arithmetic, which overflows (and panics) once the result leaves chrono’s representable range.

days below 1 is still treated as 1, as it always has been.