Time window helpers built around half-open ranges.
All windows use the convention [start_at, end_at), where start_at is
inclusive and end_at is exclusive.
Summary
Functions
True when datetime is inside the half-open window [window.start_at, window.end_at).
Fetches and validates the :window option, returning the t() map.
Returns the contiguous prior window with identical duration (in seconds).
Builds a trailing half-open window [start_at, end_at).
Returns the start timestamp of a trailing window ending at end_at.
Types
@type t() :: %{start_at: DateTime.t(), end_at: DateTime.t()}
Functions
@spec contains?(t(), DateTime.t()) :: boolean()
True when datetime is inside the half-open window [window.start_at, window.end_at).
Fetches and validates the :window option, returning the t() map.
Raises ArgumentError when :window is missing or is not a
%{start_at: DateTime.t(), end_at: DateTime.t()} map.
Returns the contiguous prior window with identical duration (in seconds).
@spec trailing(DateTime.t(), non_neg_integer(), :day | :hour | :minute | :second) :: t()
Builds a trailing half-open window [start_at, end_at).
@spec trailing_start( DateTime.t(), non_neg_integer(), :day | :hour | :minute | :second ) :: DateTime.t()
Returns the start timestamp of a trailing window ending at end_at.