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()}
|
|
|
|
}
|
|
|
|
|
2023-08-06 10:52:27 +00:00
|
|
|
// 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
|
2023-08-06 10:52:27 +00:00
|
|
|
func (cal *Calendar) GetEvents() []*Event {
|
2023-06-20 21:44:50 +00:00
|
|
|
subcal := cal.Calendar
|
|
|
|
subevents := subcal.GetEvents()
|
2023-08-06 10:52:27 +00:00
|
|
|
wrapped := make([]*Event, len(subevents))
|
2023-06-20 21:44:50 +00:00
|
|
|
for i, v := range subevents {
|
2023-08-06 10:52:27 +00:00
|
|
|
wrapped[i] = &Event{v}
|
2023-06-20 21:44:50 +00:00
|
|
|
}
|
|
|
|
return wrapped
|
|
|
|
}
|