AntlUtilsElixir.DateTime.Comparison (antl_utils_elixir v1.4.5)
Little wrapper around DateTime
Link to this section Summary
Functions
Returns whether datetime1 is equal to datetime2
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
eq?(dt1, dt2)
Specs
eq?(DateTime.t(), DateTime.t()) :: boolean()
Returns whether datetime1 is equal to datetime2
Examples
iex> Comparison.eq?(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.eq?(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
gt?(dt1, dt2)
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
gte?(dt1, dt2)
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
lt?(dt1, dt2)
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
lte?(dt1, dt2)
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
max(dt1, dt2)
Specs
max(DateTime.t(), DateTime.t()) :: DateTime.t()
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")
min(dt1, dt2)
Specs
min(DateTime.t(), DateTime.t()) :: DateTime.t()
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")