Build URLs for editing prefilled Google Calendar events
How long should the event last for?
Note: If you want an all-day event, use CustomDates
with the requested date, a /
and then the date of the following day.
Example: An all-day event for 2024-01-01
can be achieved like this:
CustomDates "20240101/20240102"
eventEditUrl : Time.Zone -> EventDetails -> Url
Create a URL for a Google Calendar Event.
import Time
import Url
import GoogleCalendar exposing (Duration(..))
Url.toString <| eventEditUrl Time.utc { title = "Some event", duration = NoDurationLetUserChoose, details = "Details about the event.\n\nMight contain newlines.", guests = [] }
--> "https://calendar.google.com/calendar/u/0/r/eventedit?text=Some%20event&details=Details%20about%20the%20event.%0A%0AMight%20contain%20newlines."
Url.toString <| eventEditUrl Time.utc { title = "Some event", duration = TimeSpan { from = Time.millisToPosix 1612508680856, to = Time.millisToPosix 1612508680856 }, details = "Details about the event.\n\nMight contain newlines.", guests = [] }
--> "https://calendar.google.com/calendar/u/0/r/eventedit?text=Some%20event&details=Details%20about%20the%20event.%0A%0AMight%20contain%20newlines.&dates=20210205T070440%2F20210205T070440"
Url.toString <| eventEditUrl Time.utc { title = "Some all-day event", duration = CustomDates "20210405/20210406", details = "Details about the event.\n\nMight contain newlines.", guests = [] }
--> "https://calendar.google.com/calendar/u/0/r/eventedit?text=Some%20all-day%20event&details=Details%20about%20the%20event.%0A%0AMight%20contain%20newlines.&dates=20210405%2F20210406"
Url.toString <| eventEditUrl Time.utc { title = "Some event with guests", duration = NoDurationLetUserChoose, details = "Details about the event.\n\nMight contain newlines.", guests = ["hello@example.com", "hi@example.com"] }
--> "https://calendar.google.com/calendar/u/0/r/eventedit?text=Some%20event%20with%20guests&details=Details%20about%20the%20event.%0A%0AMight%20contain%20newlines.&add=hello%40example.com,hi%40example.com"
{ title : String
, duration : Duration
, details : String
, guests : List String
}
Values needed for creating an event Note that the details text might contain HTML, if you want e.g. images or anchor tags.