Add status

This commit is contained in:
2022-11-02 00:25:21 +01:00
parent be9ee8372f
commit da16c90fc3
4 changed files with 267 additions and 172 deletions

View File

@@ -2,6 +2,12 @@ package storage
import "time"
const (
StatusOld = -1
StatusOngoing = 0
StatusForthcoming = 1
)
type Booking struct {
ID string `json:"id" bson:"_id"`
Vehicleid string `json:"vehicleid"`
@@ -15,3 +21,15 @@ type Booking struct {
Deleted bool
Vehicle Vehicle
}
func (b Booking) Status() int {
now := time.Now()
if b.Enddate.Before(now) {
return StatusOld
} else if b.Startdate.After(now) {
return StatusForthcoming
} else {
return StatusOngoing
}
}