ESpec v1.5.0 DateTime.Extension View Source

A module to extend the calendar implementation that follows to ISO8601 with methods found in Elixir 1.5.1. This is to allow ESpec to support Elixir >= 1.3.4 more easily.

Link to this section Summary

Link to this section Types

Link to this type t() View Source
t() :: %DateTime.Extension{calendar: Calendar.calendar(), day: Calendar.day(), hour: Calendar.hour(), microsecond: Calendar.microsecond(), minute: Calendar.minute(), month: Calendar.month(), second: Calendar.second(), std_offset: Calendar.std_offset(), time_zone: Calendar.time_zone(), utc_offset: Calendar.utc_offset(), year: Calendar.year(), zone_abbr: Calendar.zone_abbr()}

Link to this section Functions

Link to this function from_naive(naive_datetime, time_zone) View Source
from_naive(NaiveDateTime.t(), Calendar.time_zone()) :: {:ok, t()}

Converts the given NaiveDateTime to DateTime.

It expects a time zone to put the NaiveDateTime in. Currently it only supports “Etc/UTC” as time zone.

Examples

iex> {:ok, datetime} = DateTime.from_naive(~N[2016-05-24 13:26:08.003], "Etc/UTC")
iex> datetime
#DateTime<2016-05-24 13:26:08.003Z>
Link to this function from_naive!(naive_datetime, time_zone) View Source
from_naive!(NaiveDateTime.t(), Calendar.time_zone()) :: t()

Converts the given NaiveDateTime to DateTime.

It expects a time zone to put the NaiveDateTime in. Currently it only supports “Etc/UTC” as time zone.

Examples

iex> DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC")
#DateTime<2016-05-24 13:26:08.003Z>