swiss v3.4.4 Swiss.DateTime View Source
Some extra functions for working with DateTimes that aren't in the native lib or on Timex.
Link to this section Summary
Functions
Converts a ISO 8601 date into a DateTime and offset.
Returns the biggest (latest) of the given list of dates.
Returns the biggest (latest) of two dates.
Returns the smallest (earliest) of the given list of dates.
Returns the smallest (earliest) of two dates.
Helper method for getting "now" with second precision.
Link to this section Functions
Converts a ISO 8601 date into a DateTime and offset.
This is a wrapper around DateTime.from_iso8601/2
that raises on error.
Examples
iex> Swiss.DateTime.from_iso8601!("2015-01-23T23:50:07Z")
{~U[2015-01-23 23:50:07Z], 0}
Returns the biggest (latest) of the given list of dates.
Examples
iex> Swiss.DateTime.max([DateTime.from_unix!(1_577_664_000), DateTime.from_unix!(2_464_096_360), DateTime.from_unix!(1_464_096_368)])
~U[2048-01-31 15:12:40Z]
iex> Swiss.DateTime.max([DateTime.from_unix!(2_464_096_360), nil])
~U[2048-01-31 15:12:40Z]
iex> Swiss.DateTime.max([nil, nil, ~U[2020-11-09 09:00:50Z]])
~U[2020-11-09 09:00:50Z]
max(date_1, date_2)
View Sourcemax(DateTime.t(), DateTime.t()) :: DateTime.t()
Returns the biggest (latest) of two dates.
Examples
iex> Swiss.DateTime.max(DateTime.from_unix!(1_577_664_000), DateTime.from_unix!(1_464_096_368))
~U[2019-12-30 00:00:00Z]
Returns the smallest (earliest) of the given list of dates.
Examples
iex> Swiss.DateTime.min([DateTime.from_unix!(1_577_664_000), DateTime.from_unix!(2_464_096_360), DateTime.from_unix!(1_464_096_368)])
~U[2016-05-24 13:26:08Z]
iex> Swiss.DateTime.min([DateTime.from_unix!(2_464_096_360), nil])
~U[2048-01-31 15:12:40Z]
iex> Swiss.DateTime.min([nil, nil, ~U[2020-11-09 09:00:50Z]])
~U[2020-11-09 09:00:50Z]
min(date_1, date_2)
View Sourcemin(DateTime.t(), DateTime.t()) :: DateTime.t()
Returns the smallest (earliest) of two dates.
Examples
iex> Swiss.DateTime.min(DateTime.from_unix!(1_577_664_000), DateTime.from_unix!(1_464_096_368))
~U[2016-05-24 13:26:08Z]
Helper method for getting "now" with second precision.