2018-01-15 11:40:01 +01:00
|
|
|
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
|
2018-07-27 10:45:35 +02:00
|
|
|
events = [
|
|
|
|
%ICalendar.Event{
|
|
|
|
summary: event.title,
|
|
|
|
dtstart: event.begins_on,
|
|
|
|
dtend: event.ends_on,
|
|
|
|
description: event.description,
|
|
|
|
uid: event.uuid
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2018-01-15 11:40:01 +01:00
|
|
|
%ICalendar{events: events}
|
|
|
|
|> ICalendar.to_ics()
|
|
|
|
end
|
|
|
|
end
|