View Source Luminous.TimeRange behaviour (luminous v2.6.1)
This module defines a struct with two fields (:from
and :to
) to represent a time range.
Additionally, various helper functions are defined that operate on time ranges.
It also specifies a behaviour that can be (optionally) implemented by client-side dashboards in order to override the dashboard's default time range (which is "today").
Link to this section Summary
Callbacks
Implement inside a client-side dashboard in order to return the dashboard's default time range.
Functions
Convert the time range to a map of unix timestamps.
Link to this section Types
@type t() :: %Luminous.TimeRange{from: DateTime.t(), to: DateTime.t()}
@type time_zone() :: binary()
Link to this section Callbacks
Implement inside a client-side dashboard in order to return the dashboard's default time range.
Link to this section Functions
@spec add(DateTime.t(), integer(), atom()) :: DateTime.t()
@spec default_time_zone() :: time_zone()
@spec from_unix(non_neg_integer(), non_neg_integer()) :: t()
@spec last_month(time_zone(), DateTime.t() | nil) :: t()
@spec last_n_days(non_neg_integer(), time_zone(), DateTime.t() | nil) :: t()
@spec last_week(time_zone(), DateTime.t() | nil) :: t()
@spec new(DateTime.t(), DateTime.t()) :: t()
@spec round(DateTime.t(), atom()) :: DateTime.t()
@spec this_month(time_zone(), DateTime.t() | nil) :: t()
@spec this_week(time_zone(), DateTime.t() | nil) :: t()
@spec to_unix(t() | nil, t() | nil) :: %{from: non_neg_integer(), to: non_neg_integer()} | %{}
Convert the time range to a map of unix timestamps.
If the time range or any of its attributes (from, to) is nil then convert the second (default) argument to unix timestamps.
If the default is also nil, then return an empty map.
@spec today(time_zone(), DateTime.t() | nil) :: t()
@spec tomorrow(time_zone(), DateTime.t() | nil) :: t()
@spec yesterday(time_zone(), DateTime.t() | nil) :: t()