NaiveDateTime.compare
You're seeing just the function
compare
, go back to NaiveDateTime module for more information.
Specs
compare(Calendar.naive_datetime(), Calendar.naive_datetime()) :: :lt | :eq | :gt
Compares two NaiveDateTime
structs.
Returns :gt
if first is later than the second
and :lt
for vice versa. If the two NaiveDateTime
are equal :eq
is returned.
Examples
iex> NaiveDateTime.compare(~N[2016-04-16 13:30:15], ~N[2016-04-28 16:19:25])
:lt
iex> NaiveDateTime.compare(~N[2016-04-16 13:30:15.1], ~N[2016-04-16 13:30:15.01])
:gt
This function can also be used to compare a DateTime without the time zone information:
iex> dt = %DateTime{year: 2000, month: 2, day: 29, zone_abbr: "CET",
...> hour: 23, minute: 0, second: 7, microsecond: {0, 0},
...> utc_offset: 3600, std_offset: 0, time_zone: "Europe/Warsaw"}
iex> NaiveDateTime.compare(dt, ~N[2000-02-29 23:00:07])
:eq
iex> NaiveDateTime.compare(dt, ~N[2000-01-29 23:00:07])
:gt
iex> NaiveDateTime.compare(dt, ~N[2000-03-29 23:00:07])
:lt