kiwimix/pkg/basetypes/calendar.go

33 lines
651 B
Go
Raw Normal View History

2023-06-20 21:44:50 +00:00
package basetypes
import (
ics "github.com/PuloV/ics-golang"
)
// Calendar type
type Calendar struct {
ics.Calendar
}
// NewCalendar creates a new calendar
func NewCalendar() *Calendar {
return &Calendar{*ics.NewCalendar()}
}
// SetEvent adds an event to the calendar
func (cal *Calendar) SetEvent(event Event) (*Calendar, error) {
c, err := cal.SetEvent(event)
return c, err
}
// GetEvents gets all events in the calendar
func (cal *Calendar) GetEvents() []Event {
subcal := cal.Calendar
subevents := subcal.GetEvents()
wrapped := make([]Event, len(subevents))
for i, v := range subevents {
wrapped[i] = Event{v}
}
return wrapped
}