swiss v1.5.0 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

Link to this function

from_iso8601!(iso_date, calendar \\ Calendar.ISO)

View Source

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]

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]

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]
Link to this function

second_utc_now()

View Source
second_utc_now() :: DateTime.t()

Helper method for getting "now" with second precision.