Dates
When working with dates in Elixir, nerver use "<" or ">", because sometimes, it will not work the way you want
iex(16)> first = Timex.parse!("Tue, 29 Oct 2019 16:00:00 +0000", "%a, %d %b %Y %H:%M:%S %z", :strftime)
#DateTime<2019-10-29 16:00:00+00:00 GMT Etc/GMT+0>
iex(17)> second = Timex.parse!("Wed, 06 Nov 2019 23:00:00 +0000", "%a, %d %b %Y %H:%M:%S %z", :strftime)
#DateTime<2019-11-06 23:00:00+00:00 GMT Etc/GMT+0>
iex(18)> first < second
false
Timex
For example, with Timex
comes the compare
function.
Timex.compare(first, second)
-1
And return value should be considered as follow :
- -1 : first is before second
- 0 : first is equal to second
- 1 : second is before first