diff --git a/calendar.go b/calendar.go index 5b3d7c4..9ab15d3 100644 --- a/calendar.go +++ b/calendar.go @@ -408,7 +408,12 @@ func NewEvent(uniqueId string) *VEvent { e := &VEvent{ ComponentBase{ Properties: []IANAProperty{ - {BaseProperty{IANAToken: ToText(string(ComponentPropertyUniqueId)), Value: uniqueId}}, + { + BaseProperty{ + IANAToken: ToText(string(ComponentPropertyUniqueId)), + Value: uniqueId, + }, + }, }, }, } @@ -425,6 +430,22 @@ func (calendar *Calendar) AddVEvent(e *VEvent) { calendar.Components = append(calendar.Components, e) } +func (calendar *Calendar) RemoveEvent(id string) { + for i := range calendar.Components { + switch event := calendar.Components[i].(type) { + case *VEvent: + if event.Id() == id { + if len(calendar.Components) > i+1 { + calendar.Components = append(calendar.Components[:i], calendar.Components[i+1:]...) + } else { + calendar.Components = calendar.Components[:i] + } + return + } + } + } +} + func (calendar *Calendar) Events() (r []*VEvent) { r = []*VEvent{} for i := range calendar.Components {