Export an event though ics

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-01-15 11:40:01 +01:00
parent a1f60cf386
commit 8414f9a098
4 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
defmodule Eventos.Export.ICalendar do
@moduledoc """
Export an event to iCalendar format
"""
alias Eventos.Events.Event
@spec export_event(%Event{}) :: String
def export_event(%Event{} = event) do
events = [%ICalendar.Event{
summary: event.title,
dtstart: event.begins_on,
dtend: event.ends_on,
description: event.description
}]
%ICalendar{events: events}
|> ICalendar.to_ics()
end
end