Initial commit
This commit is contained in:
25
storage/vehicles.go
Normal file
25
storage/vehicles.go
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user