33 lines
651 B
Go
33 lines
651 B
Go
|
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
|
||
|
}
|