View Source ExCycle.State (ex_cycle v0.5.6)
The ExCycle.State
represents the state of the next generated datetime.
Summary
Functions
Creates a new state.
The next
dates will be the same as origin
.
Creates a new state specifying the origin
and the next
(aka from
is this context).
Resets the state.
update_next/3
is an helper to update the next value.
Types
@type datetime() :: Date.t() | DateTime.t() | NaiveDateTime.t()
@type t() :: %ExCycle.State{ exhausted?: boolean(), iteration: non_neg_integer(), next: NaiveDateTime.t(), origin: NaiveDateTime.t(), result: DateTime.t() | NaiveDateTime.t() | ExCycle.Span.t() | nil }
Functions
Creates a new state.
The next
dates will be the same as origin
.
Examples
iex> new(~D[2024-01-01])
%ExCycle.State{origin: ~N[2024-01-01 00:00:00], next: ~N[2024-01-01 00:00:00]}
iex> new(~N[2024-01-01 10:00:00])
%ExCycle.State{origin: ~N[2024-01-01 10:00:00], next: ~N[2024-01-01 10:00:00]}
Creates a new state specifying the origin
and the next
(aka from
is this context).
Examples
iex> new(~D[2024-01-01], ~D[2024-02-02])
%ExCycle.State{origin: ~N[2024-01-01 00:00:00], next: ~N[2024-02-02 00:00:00]}
iex> new(~N[2024-01-01 10:00:00], ~D[2024-02-02])
%ExCycle.State{origin: ~N[2024-01-01 10:00:00], next: ~N[2024-02-02 00:00:00]}
iex> new(~N[2024-01-01 10:00:00], ~N[2024-02-02 10:00:00])
%ExCycle.State{origin: ~N[2024-01-01 10:00:00], next: ~N[2024-02-02 10:00:00]}
Resets the state.
By resetting, we means set the origin
value equal to next
value.
Examples
iex> reset(%ExCycle.State{origin: ~N[2024-03-01 00:00:00], next: ~N[2024-06-01 00:00:00]})
%ExCycle.State{origin: ~N[2024-06-01 00:00:00], next: ~N[2024-06-01 00:00:00]}
update_next/3
is an helper to update the next value.