26 lines
718 B
Go
26 lines
718 B
Go
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
|
|
}
|