Build URLs for editing prefilled Google Calendar events
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." }
--> "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." }
--> "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." }
--> "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"Values needed for creating an event Note that the details text might contain HTML, if you want e.g. images or anchor tags.
How long should the event last for? Note: If you want an all-day event, use
CustomDateswith the requested date, a/and then the date of the following day. Example: An all-day event for2024-01-01can be achieved like this: