arran4 / golang-ical

A ICS / ICal parser and serialiser for Golang.
Apache License 2.0
279 stars 72 forks source link

how to do a event reminder? #93

Open liangminghaoAngus opened 2 weeks ago

liangminghaoAngus commented 2 weeks ago

well,is that a example to tell me how to do a simple event reminder? i have not found a example about it... such as a event start at 09:00,i want a reminder at 07:00 i do make a event for cal,but have not idea to make a reminder

arran4 commented 2 weeks ago

Hi @liangminghaoAngus

This is just a serializer / deserializer. I do need to create some documentation for it.

So I created a calendar (using KOrganizer)

006fc755-dda4-41a6-b477-0b187a1ac447.zip

The part of interest is at the end:

BEGIN:VEVENT
DTSTAMP:20240618T233745Z
CREATED:20240618T233745Z
UID:006fc755-dda4-41a6-b477-0b187a1ac447
LAST-MODIFIED:20240618T233745Z
SUMMARY:test
LOCATION:test
DTSTART;TZID=Australia/Melbourne:20240619T100000
DTEND;TZID=Australia/Melbourne:20240619T101500
TRANSP:OPAQUE
BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER:-PT5M
X-KDE-KCALCORE-ENABLED:TRUE
END:VALARM
END:VEVENT

That's the whole event. We are interested in the VALARM part:

BEGIN:VALARM
DESCRIPTION:
ACTION:DISPLAY
TRIGGER:-PT5M
X-KDE-KCALCORE-ENABLED:TRUE
END:VALARM

So that's for this event:

image

It's nested. I haven't used the library in a while, but if you can't do that in it, that's a bug.

arran4 commented 2 weeks ago

I have some things on my plate but let me know how you go, I will attempt to follow up. If needed follow through with a fix.

liangminghaoAngus commented 2 weeks ago

thx ,i found the way to use it.here is my code ,it works and it is needed to create some documentation for it.

            reminder := ics.NewAlarm(uuidString)
            reminder.SetSummary(summary)
            reminder.SetDescription(description)
            reminder.SetAction(ics.ActionDisplay)
            reminder.SetTrigger("-PT2H")
            event.AddVAlarm(reminder)
arran4 commented 2 weeks ago

Awesome.