antikythera v0.2.0 Antikythera.Time View Source

Data structure to represent date and time in milli-seconds resolution.

Note that all values of Antikythera.Time.t are in UTC.

Poison.Encoder protocol is implemented for Antikythera.Time.t, so that values of this type can be directly converted to Antikythera.IsoTimestamp.t on Poison.encode/1.

iex> Poison.encode(%{time: {Antikythera.Time, {2017, 1, 1}, {0, 0, 0}, 0}})
{:ok, "{"time":"2017-01-01T00:00:00.000+00:00"}"}

See also new/1.

Link to this section Summary

Link to this section Types

Link to this type t() View Source
t() :: {Antikythera.Time, :calendar.date(), :calendar.time(), milliseconds()}

Link to this section Functions

Link to this function diff_milliseconds(t1, t2) View Source
diff_milliseconds(t(), t()) :: integer()
Link to this function from_epoch_milliseconds(milliseconds) View Source
from_epoch_milliseconds(integer()) :: t()
Link to this function from_gregorian_milliseconds(milliseconds) View Source
from_gregorian_milliseconds(integer()) :: t()
Link to this function from_http_date(s) View Source
from_http_date(String.t()) :: Croma.Result.t(t())

Parses HTTP-date formats into Antikythera.Time.t.

Supports IMF-fixdate format, RFC 850 format and ANSI C’s asctime() format for compatibility.

Note: An HTTP-date value must represents time in UTC(GMT). Thus timezone string in the end must always be ‘GMT’. Any other timezone string (such as ‘JST’) will actually be ignored and parsed as GMT.

https://tools.ietf.org/html/rfc7231#section-7.1.1.1

Link to this function from_http_date!(arg0) View Source
from_http_date!(String.t()) :: t()
Link to this function from_iso_basic(s) View Source
from_iso_basic(String.t()) :: Croma.Result.t(t())
Link to this function from_iso_basic!(arg0) View Source
from_iso_basic!(String.t()) :: t()
Link to this function from_iso_timestamp(s) View Source
from_iso_timestamp(String.t()) :: Croma.Result.t(t())
Link to this function from_iso_timestamp!(arg0) View Source
from_iso_timestamp!(String.t()) :: t()

Convert timestamps into Antikythera.Time.t, leveraging recursive_new? option of Croma.Struct.

Only Antikythera.IsoTimestamp.t can be converted.

Link to this function shift_days(t, days) View Source
shift_days(t(), integer()) :: t()
Link to this function shift_hours(t, hours) View Source
shift_hours(t(), integer()) :: t()
Link to this function shift_milliseconds(t, milliseconds) View Source
shift_milliseconds(t(), integer()) :: t()
Link to this function shift_minutes(t, minutes) View Source
shift_minutes(t(), integer()) :: t()
Link to this function shift_seconds(t, seconds) View Source
shift_seconds(t(), integer()) :: t()
Link to this function to_epoch_milliseconds(t) View Source
to_epoch_milliseconds(t()) :: integer()
Link to this function to_gregorian_milliseconds(a0) View Source
to_gregorian_milliseconds(t()) :: integer()

Returns date/time in IMF-fixdate format.

The format is subset of Internet Message Format (RFC5322, formarly RFC822, RFC1123). Defined as ‘preferred’ format in RFC7231 and modern web servers or clients should send in this format.

https://tools.ietf.org/html/rfc7231#section-7.1.1.1

Link to this function to_iso_timestamp(a0) View Source
to_iso_timestamp(t()) :: Antikythera.IsoTimestamp.t()
Link to this function truncate_to_day(a0) View Source
truncate_to_day(t()) :: t()
Link to this function truncate_to_hour(a0) View Source
truncate_to_hour(t()) :: t()
Link to this function truncate_to_minute(a0) View Source
truncate_to_minute(t()) :: t()
Link to this function truncate_to_second(a0) View Source
truncate_to_second(t()) :: t()