kiwimix/pkg/basetypes/calendar.go

56 lines
1.3 KiB
Go
Raw Permalink 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()}
}
// ParseCalendarFile parses an ICS file and returns a calendar
func ParseCalendarFile(filePath string) (*Calendar, error) {
return &Calendar{*ics.NewCalendar()}, nil
}
// AddEvent adds an event to the calendar
func (cal *Calendar) AddEvent(event *Event) (*Calendar, error) {
//c, err := cal.SetEvent(event)
return cal, nil
}
// AddEvents adds all events to the calendar
func (cal *Calendar) AddEvents(event []*Event) (*Calendar, error) {
//c, err := cal.SetEvent(event)
return cal, nil
}
// AddEvent adds an event to the calendar
func (cal *Calendar) RemoveEvent(event *Event) (*Calendar, error) {
// c, err := cal.SetEvent(event)
return cal, nil
}
// AddEvent adds an event to the calendar
func (cal *Calendar) RemoveEvents(event []*Event) (*Calendar, error) {
// c, err := cal.SetEvent(event)
return cal, nil
2023-06-20 21:44:50 +00:00
}
// GetEvents gets all events in the calendar
func (cal *Calendar) GetEvents() []*Event {
2023-06-20 21:44:50 +00:00
subcal := cal.Calendar
subevents := subcal.GetEvents()
wrapped := make([]*Event, len(subevents))
2023-06-20 21:44:50 +00:00
for i, v := range subevents {
wrapped[i] = &Event{v}
2023-06-20 21:44:50 +00:00
}
return wrapped
}