fleets/storage/vehicles.go

26 lines
718 B
Go
Raw Normal View History

2022-08-12 12:49:16 +00:00
package storage
import "time"
type Vehicle struct {
ID string `json:"id" bson:"_id"`
Type string `json:"type"`
Namespace string `json:"namespace"`
Administrators []string `json:"administrators"`
Data map[string]any `json:"data"`
Metadata map[string]any `json:"metadata"`
Bookings []Booking
}
func (v Vehicle) Free(start time.Time, end time.Time) bool {
for _, b := range v.Bookings {
if (start.After(b.Unavailablefrom) && start.Before(b.Unavailableto)) ||
(end.After(b.Unavailablefrom) && end.Before(b.Unavailableto)) ||
(start.Before(b.Unavailablefrom) && end.After(b.Unavailableto)) {
return false
}
}
return true
}