2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Export.ICalendar do
|
2018-01-15 11:40:01 +01:00
|
|
|
@moduledoc """
|
|
|
|
Export an event to iCalendar format
|
|
|
|
"""
|
|
|
|
|
2018-10-11 17:37:39 +02:00
|
|
|
alias Mobilizon.Events.Event
|
2018-01-15 11:40:01 +01:00
|
|
|
|
|
|
|
@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
|