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

Build iCalendar format strings from schedules.

TODO: write long description

Link to this section Summary

Functions

Builds an iCalendar format string representation of a Cocktail.Schedule.t/0.

Builds an iCalendar RRULE format string representation of a Cocktail.Schedule.t/0

Link to this section Functions

@spec build(Cocktail.Schedule.t()) :: String.t()

Builds an iCalendar format string representation of a Cocktail.Schedule.t/0.

examples

Examples

iex> alias Cocktail.Schedule
...> start_time = Timex.to_datetime(~N[2017-01-01 06:00:00], "America/Los_Angeles")
...> schedule = Schedule.new(start_time)
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, interval: 2, hours: [10, 12])
...> build(schedule)
"DTSTART;TZID=America/Los_Angeles:20170101T060000\nRRULE:FREQ=DAILY;INTERVAL=2;BYHOUR=10,12"

iex> alias Cocktail.Schedule
...> schedule = Schedule.new(~N[2017-01-01 06:00:00])
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, until: ~N[2017-01-31 11:59:59])
...> build(schedule)
"DTSTART:20170101T060000\nRRULE:FREQ=DAILY;UNTIL=20170131T115959"

iex> alias Cocktail.Schedule
...> schedule = Schedule.new(~N[2017-01-01 06:00:00])
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, count: 3)
...> build(schedule)
"DTSTART:20170101T060000\nRRULE:FREQ=DAILY;COUNT=3"
@spec build_rule(Cocktail.Schedule.t()) :: String.t()

Builds an iCalendar RRULE format string representation of a Cocktail.Schedule.t/0

examples

Examples

iex> alias Cocktail.Schedule
...> start_time = Timex.to_datetime(~N[2017-01-01 06:00:00], "America/Los_Angeles")
...> schedule = Schedule.new(start_time)
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, interval: 2, hours: [10, 12])
...> build_rule(schedule)
"RRULE:FREQ=DAILY;INTERVAL=2;BYHOUR=10,12"

iex> alias Cocktail.Schedule
...> schedule = Schedule.new(~N[2017-01-01 06:00:00])
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, until: ~N[2017-01-31 11:59:59])
...> build_rule(schedule)
"RRULE:FREQ=DAILY;UNTIL=20170131T115959"

iex> alias Cocktail.Schedule
...> schedule = Schedule.new(~N[2017-01-01 06:00:00])
...> schedule = Schedule.add_recurrence_rule(schedule, :daily, count: 3)
...> build_rule(schedule)
"RRULE:FREQ=DAILY;COUNT=3"