AntlUtilsElixir.DateTime.Comparison (antl_utils_elixir v0.3.0)

Little wrapper around DateTime

Link to this section Summary

Functions

Returns whether datetime1 is greater than datetime2

Returns whether datetime1 is greater than or equal to datetime2

Returns whether datetime1 is less than datetime2

Returns whether datetime1 is less than or equal to datetime2

Returns the max date between datetime1 and datetime2

Returns the min date between datetime1 and datetime2

Link to this section Functions

Specs

gt?(DateTime.t(), DateTime.t()) :: boolean()

Returns whether datetime1 is greater than datetime2

Examples

iex> Comparison.gt?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
false

iex> Comparison.gt?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
false

iex> Comparison.gt?(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
true

Specs

gte?(DateTime.t(), DateTime.t()) :: boolean()

Returns whether datetime1 is greater than or equal to datetime2

Examples

iex> Comparison.gte?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
false

iex> Comparison.gte?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
true

iex> Comparison.gte?(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
true

Specs

lt?(DateTime.t(), DateTime.t()) :: boolean()

Returns whether datetime1 is less than datetime2

Examples

iex> Comparison.lt?(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
false

iex> Comparison.lt?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
false

iex> Comparison.lt?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
true

Specs

lte?(DateTime.t(), DateTime.t()) :: boolean()

Returns whether datetime1 is less than or equal to datetime2

Examples

iex> Comparison.lte?(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
false

iex> Comparison.lte?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
true

iex> Comparison.lte?(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
true

Specs

Returns the max date between datetime1 and datetime2

Examples

iex> Comparison.max(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC")

iex> Comparison.max(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC")

iex> Comparison.max(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC")

Specs

Returns the min date between datetime1 and datetime2

Examples

iex> Comparison.min(DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC")

iex> Comparison.min(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC")

iex> Comparison.min(DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC"), DateTime.from_naive!(~N[2018-01-02 00:00:00], "Etc/UTC"))
DateTime.from_naive!(~N[2018-01-01 00:00:00], "Etc/UTC")