// GetData gets the requested calendar data from the provider.
GetData gets the requested calendar data from the provider.
// GetData gets the requested calendar data from the provider .
func (p *Provider) GetData(db *sql.DB, user *data.User, location *time.Location, startTime time.Time, endTime time.Time, dataType data.ProviderDataType) (data.ProviderData, error) {
	startUnix := startTime.Unix()
	endUnix := endTime.Unix()
	rows, err := db.Query(
		"SELECT uid, name, start, end, calendarID FROM calendar_external_events WHERE calendarID = ? AND start >= ? AND end <= ?",
		p.ExternalCalendarID,
		startUnix,
		endUnix,
	)
	if err != nil {
		return data.ProviderData{}, err
	}
	result := data.ProviderData{
		Announcements: []data.PlannerAnnouncement{},
		Events:        []data.Event{},
	}
	for rows.Next() {
		externalEvent := externalEvent{}
		err = rows.Scan(&externalEvent.UID, &externalEvent.Name, &externalEvent.Start, &externalEvent.End, &externalEvent.CalendarID)
		if err != nil {
			return data.ProviderData{}, err
		}
		event := data.Event{
			ID:            -1,
			UniqueID:      externalEvent.UID,
			Name:          externalEvent.Name,
			Start:         int(externalEvent.Start),
			End:           int(externalEvent.End),
			StartTimezone: "America/New_York", 
			EndTimezone:   "America/New_York", 
			RecurRule:     nil,
			Tags: map[data.EventTagType]interface{}{
				data.EventTagReadOnly: true,
			},
		}
		result.Events = append(result.Events, event)
	}
	return result, nil
}
func ( p * Provider ) GetData ( db * sql . DB , user * data . User , location * time . Location , startTime time . Time , endTime time . Time , dataType data . ProviderDataType ) ( data . ProviderData , error ) { startUnix := startTime . Unix ( ) endUnix := endTime . Unix ( ) rows , err := db . Query ( " " , p . ExternalCalendarID , startUnix , endUnix , ) if err != nil { return data . ProviderData { } , err } result := data . ProviderData { Announcements : [ ] data . PlannerAnnouncement { } , Events : [ ] data . Event { } , } for rows . Next ( ) { externalEvent := externalEvent { } err = rows . Scan ( & externalEvent . UID , & externalEvent . Name , & externalEvent . Start , & externalEvent . End , & externalEvent . CalendarID ) if err != nil { return data . ProviderData { } , err } event := data . Event { ID : - 1 , UniqueID : externalEvent . UID , Name : externalEvent . Name , Start : int ( externalEvent . Start ) , End : int ( externalEvent . End ) , StartTimezone : " " , EndTimezone : " " , RecurRule : nil , Tags : map [ data . EventTagType ] interface { } { data . EventTagReadOnly : true , } , } result . Events = append ( result . Events , event ) } return result , nil }
GetData gets the requested calendar data from the provider.
GetData gets the requested calendar data from the provider .
// TODO: make this part of the event // TODO: make this part of the event