Kalends.Parser

Summary

parse_rfc3339(rfc3339_string, time_zone)

Parses an RFC 3339 timestamp and shifts it to the specified time zone

Functions

parse_rfc3339(rfc3339_string, time_zone)

Parses an RFC 3339 timestamp and shifts it to the specified time zone.

iex> parse_rfc3339("1996-12-19T16:39:57Z", "UTC")
{:ok, %Kalends.DateTime{year: 1996, month: 12, date: 19, hour: 16, min: 39, sec: 57, timezone: "UTC", abbr: "UTC", std_off: 0, utc_off: 0}}

iex> parse_rfc3339("1996-12-19T16:39:57-8:00", "America/Los_Angeles")
{:ok, %Kalends.DateTime{abbr: "PST", date: 19, hour: 16, min: 39, month: 12, sec: 57, std_off: 0, timezone: "America/Los_Angeles", utc_off: -28800, year: 1996}}

iex> parse_rfc3339("invalid", "America/Los_Angeles")
{:bad_format, nil}

iex> parse_rfc3339("1996-12-19T16:39:57-08:00", "invalid time zone name")
{:invalid_time_zone, nil}