Caracola.Date (Caracola v0.1.0-rc.1)

Copy Markdown View Source

Date header values (RFC 3261 §20.17), in the RFC 1123 form that SIP requires, always in GMT:

iex> Caracola.Date.encode(~U[2010-11-13 23:29:00Z])
"Sat, 13 Nov 2010 23:29:00 GMT"

iex> Caracola.Date.parse("Sat, 13 Nov 2010 23:29:00 GMT")
{:ok, ~U[2010-11-13 23:29:00Z]}

Summary

Functions

Encodes a DateTime (converted to UTC) as a Date value.

Returns the current time as a Date value.

Parses a Date value. The day name is optional, as RFC 1123 allows, but must match the date if present.

Functions

encode(datetime)

@spec encode(DateTime.t()) :: String.t()

Encodes a DateTime (converted to UTC) as a Date value.

now()

@spec now() :: String.t()

Returns the current time as a Date value.

parse(bin)

@spec parse(binary()) :: {:ok, DateTime.t()} | :error

Parses a Date value. The day name is optional, as RFC 1123 allows, but must match the date if present.