Kernel.sigil_U
You're seeing just the macro
sigil_U
, go back to Kernel module for more information.
Handles the sigil ~U
to create a UTC DateTime
.
By default, this sigil uses the built-in Calendar.ISO
, which
requires UTC date times to be written in the ISO8601 format:
~U[yyyy-mm-dd hh:mm:ssZ]
~U[yyyy-mm-dd hh:mm:ss.ssssssZ]
~U[yyyy-mm-ddThh:mm:ss.ssssss+00:00]
such as:
~U[2015-01-13 13:00:07Z]
~U[2015-01-13T13:00:07.123+00:00]
If you are using alternative calendars, any representation can be used as long as you follow the representation by a single space and the calendar name:
~U[SOME-REPRESENTATION My.Alternative.Calendar]
The given datetime_string
must include "Z" or "00:00" offset
which marks it as UTC, otherwise an error is raised.
The lower case ~u
variant does not exist as interpolation
and escape characters are not useful for date time sigils.
More information on date times can be found in the DateTime
module.
Examples
iex> ~U[2015-01-13 13:00:07Z]
~U[2015-01-13 13:00:07Z]
iex> ~U[2015-01-13T13:00:07.001+00:00]
~U[2015-01-13 13:00:07.001Z]