Time.compare
You're seeing just the function
compare
, go back to Time module for more information.
Specs
compare(Calendar.time(), Calendar.time()) :: :lt | :eq | :gt
Compares two time structs.
Returns :gt
if first time is later than the second
and :lt
for vice versa. If the two times are equal
:eq
is returned.
Examples
iex> Time.compare(~T[16:04:16], ~T[16:04:28])
:lt
iex> Time.compare(~T[16:04:16], ~T[16:04:16])
:eq
iex> Time.compare(~T[16:04:16.01], ~T[16:04:16.001])
:gt
This function can also be used to compare across more complex calendar types by considering only the time fields:
iex> Time.compare(~N[1900-01-01 16:04:16], ~N[2015-01-01 16:04:16])
:eq
iex> Time.compare(~N[2015-01-01 16:04:16], ~N[2015-01-01 16:04:28])
:lt
iex> Time.compare(~N[2015-01-01 16:04:16.01], ~N[2000-01-01 16:04:16.001])
:gt