mirror of
https://github.com/ZSCNetSupportDept/scheduler.git
synced 2025-10-29 04:55:04 +08:00
改进排班的算法:现在可以每周轮换一次片区,而且现在将结构体给模板
This commit is contained in:
14
handler/utils.go
Normal file
14
handler/utils.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/golang-module/carbon/v2"
|
||||
"zsxyww.com/scheduler/config"
|
||||
)
|
||||
|
||||
// 输入一个时间,返回时间是第几周的第几天
|
||||
func getWorkDay(in carbon.Carbon) (weekOffset int, dayOffset int) {
|
||||
time := carbon.Parse(config.StartTime)
|
||||
_weekOffset := time.DiffInWeeks(in)
|
||||
_dayOffset := in.DayOfWeek()
|
||||
return int(_weekOffset), _dayOffset
|
||||
}
|
||||
Reference in New Issue
Block a user