Skip to content

Commit

Permalink
Merge pull request #90 from zachmann/master
Browse files Browse the repository at this point in the history
Re-add Calendar.RemoveEvent method
  • Loading branch information
arran4 committed Apr 11, 2024
2 parents 84a339a + 02c6335 commit 9fab3f0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,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 {
Expand Down

0 comments on commit 9fab3f0

Please sign in to comment.