预约时间修正

This commit is contained in:
yan.y
2025-02-18 18:13:25 +08:00
parent 0080963f2b
commit 1898623537
3 changed files with 24 additions and 1 deletions
+22
View File
@@ -217,6 +217,28 @@ func ProcessOrders(orders []OrderTemp, maxCars int, maxDays int) OrderServiceTim
isOccupied = true
}
// 获取当前时间
currentTime := time.Now()
// 指定时区,例如 "Asia/Shanghai"
location, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
fmt.Println("Error loading location:", err)
continue
}
// 如果当前时间 >= 当前时间段的开始时间,则直接标记为占用
slotTime, err := time.ParseInLocation("2006-01-02 15:04:05", slot, location)
if err != nil {
fmt.Println("Error parsing time slot:", err)
continue
}
// 如果当前时间大于等于这个时间段的开始时间,则表示该时间段已经占用
if currentTime.UnixMilli() >= slotTime.UnixMilli() {
isOccupied = true
}
// 提取日期作为 key
date := slot[:10]