Skip to content

Commit 9256143

Browse files
Mention alternatives to compare/2 for comparison in other dates and times (#14151)
1 parent 38f460e commit 9256143

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lib/elixir/lib/calendar/date.ex

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ defmodule Date do
3131
3232
Comparisons in Elixir using `==/2`, `>/2`, `</2` and similar are structural
3333
and based on the `Date` struct fields. For proper comparison between
34-
dates, use the `compare/2` function. The existence of the `compare/2`
35-
function in this module also allows using `Enum.min/2` and `Enum.max/2`
36-
functions to get the minimum and maximum date of an `Enum`. For example:
34+
dates, use the `compare/2`, `after?/2` and `before?/2` functions.
35+
The existence of the `compare/2` function in this module also allows
36+
using `Enum.min/2` and `Enum.max/2` functions to get the minimum and
37+
maximum date of an `Enum`. For example:
3738
3839
iex> Enum.min([~D[2017-03-31], ~D[2017-04-01]], Date)
3940
~D[2017-03-31]

lib/elixir/lib/calendar/naive_datetime.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ defmodule NaiveDateTime do
3636
3737
Comparisons in Elixir using `==/2`, `>/2`, `</2` and similar are structural
3838
and based on the `NaiveDateTime` struct fields. For proper comparison
39-
between naive datetimes, use the `compare/2` function. The existence of the
40-
`compare/2` function in this module also allows using `Enum.min/2` and
41-
`Enum.max/2` functions to get the minimum and maximum naive datetime of an
42-
`Enum`. For example:
39+
between naive datetimes, use the `compare/2`, `after?/2` and `before?/2` functions.
40+
The existence of the `compare/2` function in this module also allows
41+
using `Enum.min/2` and `Enum.max/2` functions to get the minimum and
42+
maximum naive datetime of an `Enum`. For example:
4343
4444
iex> Enum.min([~N[2020-01-01 23:00:07], ~N[2000-01-01 23:00:07]], NaiveDateTime)
4545
~N[2000-01-01 23:00:07]

lib/elixir/lib/calendar/time.ex

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ defmodule Time do
3131
3232
Comparisons in Elixir using `==/2`, `>/2`, `</2` and similar are structural
3333
and based on the `Time` struct fields. For proper comparison between
34-
times, use the `compare/2` function. The existence of the `compare/2`
35-
function in this module also allows using `Enum.min/2` and `Enum.max/2`
36-
functions to get the minimum and maximum time of an `Enum`. For example:
34+
times, use the `compare/2`, `after?/2` and `before?/2` functions.
35+
The existence of the `compare/2` function in this module also allows
36+
using `Enum.min/2` and `Enum.max/2` functions to get the minimum and
37+
maximum time of an `Enum`. For example:
3738
3839
iex> Enum.min([~T[23:00:07.001], ~T[10:00:07.001]], Time)
3940
~T[10:00:07.001]

0 commit comments

Comments
 (0)