vobject v0.1.0 ICalendar.Util.Deserialize View Source

Deserialize ICalendar Strings into Event structs

Link to this section Summary

Functions

This function should strip any sanitization that has been applied to content within an iCal string

This function extracts the key and value parts from each line of a iCalendar string

This function extracts parameter data from a key in an iCalendar string

This function is designed to parse iCal datetime strings into erlang dates

Link to this section Functions

This function should strip any sanitization that has been applied to content within an iCal string.

iex> ICalendar.Util.Deserialize.desanitized(~s(lorem\\, ipsum))
"lorem, ipsum"

This function extracts the key and value parts from each line of a iCalendar string.

iex> ICalendar.Util.Deserialize.retrieve_kvs("lorem:ipsum")
%ICalendar.Property{key: "LOREM", params: %{}, value: "ipsum"}

This function extracts parameter data from a key in an iCalendar string.

iex> ICalendar.Util.Deserialize.retrieve_params(
...>   "DTSTART;TZID=America/Chicago")
["DTSTART", %{"TZID" => "America/Chicago"}]

It should be able to handle multiple parameters per key:

iex> ICalendar.Util.Deserialize.retrieve_params(
...>   "KEY;LOREM=ipsum;DOLOR=sit")
["KEY", %{"LOREM" => "ipsum", "DOLOR" => "sit"}]
Link to this function to_date(date_string, map) View Source

This function is designed to parse iCal datetime strings into erlang dates.

It should be able to handle dates from the past:

iex> {:ok, date} = ICalendar.Util.Deserialize.to_date("19930407T153022Z")
...> Timex.to_erl(date)
{{1993, 4, 7}, {15, 30, 22}}

As well as the future:

iex> {:ok, date} = ICalendar.Util.Deserialize.to_date("39930407T153022Z")
...> Timex.to_erl(date)
{{3993, 4, 7}, {15, 30, 22}}

And should return error for incorrect dates:

iex> ICalendar.Util.Deserialize.to_date("1993/04/07")
{:error, "Expected `2 digit month` at line 1, column 5."}

It should handle timezones from the Olson Database:

iex> {:ok, date} = ICalendar.Util.Deserialize.to_date("19980119T020000",
...> %{"TZID" => "America/Chicago"})
...> [Timex.to_erl(date), date.time_zone]
[{{1998, 1, 19}, {2, 0, 0}}, "America/Chicago"]