View Source Cocktail.Parser.ICalendar (Cocktail v0.10.3)

Create schedules from iCalendar format.

TODO: write long description

Link to this section Summary

Functions

Parses a string in iCalendar format into a Cocktail.Schedule.t/0.

Link to this section Functions

Link to this function

parse(i_calendar_string)

View Source
@spec parse(String.t()) :: {:ok, Cocktail.Schedule.t()} | {:error, term()}

Parses a string in iCalendar format into a Cocktail.Schedule.t/0.

examples

Examples

iex> {:ok, schedule} = parse("DTSTART;TZID=America/Los_Angeles:20170810T160000\nRRULE:FREQ=DAILY;INTERVAL=2")
...> schedule
#Cocktail.Schedule<Every 2 days>

iex> {:ok, schedule} = parse("DTSTART;TZID=America/Los_Angeles:20170810T160000\nRRULE:FREQ=WEEKLY")
...> schedule
#Cocktail.Schedule<Weekly>

iex> {:ok, schedule} = parse("DTSTART;TZID=America/Los_Angeles:20170810T160000\nRRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR")
...> schedule
#Cocktail.Schedule<Weekly on Mondays, Wednesdays and Fridays>

iex> {:ok, schedule} = parse("DTSTART;TZID=America/Los_Angeles:20170810T160000\nRRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE,FR;BYHOUR=10,12,14")
...> schedule
#Cocktail.Schedule<Every 2 weeks on Mondays, Wednesdays and Fridays on the 10th, 12th and 14th hours of the day>