AddToCalendar (add_to_calendar v0.1.0)

Copy Markdown View Source

Server-side calendar link and ICS generation for Phoenix LiveView apps.

Generates calendar provider URLs and downloadable .ics files from plain Elixir Date / Time structs — no JavaScript dependency, no timezone database required.

Quick start

event = %AddToCalendar.Event{
  name: "Pickleball League",
  start_date: ~D[2026-07-15],
  start_time: ~T[09:00:00],
  end_date: ~D[2026-07-15],
  end_time: ~T[11:00:00],
  timezone: "Pacific/Auckland",
  location: "123 Main St, Auckland",
  description: "Weekly round-robin"
}

AddToCalendar.google_url(event)
# => "https://calendar.google.com/calendar/render?..."

AddToCalendar.ics_content(event)
# => "BEGIN:VCALENDAR\r\n..."

Phoenix component

See AddToCalendar.Component.calendar_button/1 for a ready-made dropdown component (requires phoenix_live_view).

Summary

Functions

Returns the Google Calendar URL for the event.

Returns the RFC 5545 iCalendar (.ics) content for the event.

Returns a data:text/calendar;base64,... URI suitable for an <a download> link.

Returns a filename for the .ics download (slugified event name).

Returns the Outlook.com calendar URL for the event.

Functions

google_url(event)

@spec google_url(AddToCalendar.Event.t()) :: String.t()

Returns the Google Calendar URL for the event.

ics_content(event)

@spec ics_content(AddToCalendar.Event.t()) :: String.t()

Returns the RFC 5545 iCalendar (.ics) content for the event.

ics_data_uri(event)

@spec ics_data_uri(AddToCalendar.Event.t()) :: String.t()

Returns a data:text/calendar;base64,... URI suitable for an <a download> link.

ics_filename(event)

@spec ics_filename(AddToCalendar.Event.t()) :: String.t()

Returns a filename for the .ics download (slugified event name).

outlook_url(event)

@spec outlook_url(AddToCalendar.Event.t()) :: String.t()

Returns the Outlook.com calendar URL for the event.