Example #1
0
func createServiceFromCalendarDates(r map[string]string, services map[string]*gtfs.Service) *gtfs.Service {
	update := false
	var service *gtfs.Service

	// first, check if the service already exists
	if val, ok := services[getString("service_id", r, true)]; ok {
		service = val
		update = true
	} else {
		service = new(gtfs.Service)
		service.Id = getString("service_id", r, true)
	}

	// create exception
	exc := new(gtfs.ServiceException)
	var t int
	t = getInt("exception_type", r, true)
	exc.Type = int8(t)
	exc.Date = getDate("date", r, true)

	service.Exceptions = append(service.Exceptions, exc)

	if update {
		return nil
	} else {
		return service
	}
}