wanjianli
2023-09-18 690dd891f8ee47b6036eb87c239275490ee02b7f
pkg/timex/timex.go
@@ -2,7 +2,6 @@
import (
   "time"
   "wms/constvar"
)
func StringToTime(timeStr string) (time.Time, error) {
@@ -56,31 +55,4 @@
func GetCurrentTime() string {
   return time.Now().Format(timeLayout)
}
func NextDateTimestamp(base time.Time, unit constvar.InspectCycleUnit, cycle int) time.Time {
   var t time.Time
   switch unit {
   case constvar.InspectCycleUnitWeek:
      t = base.AddDate(0, 0, cycle*7)
   case constvar.InspectCycleUnitMonth:
      t = base.AddDate(0, cycle, 0)
   case constvar.InspectCycleUnitDay:
      t = base.AddDate(0, 0, cycle)
   }
   return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
}
// Cycle2Seconds 周期换算成秒数
func Cycle2Seconds(unit constvar.InspectCycleUnit, cycle int) int {
   var s int
   switch unit {
   case constvar.InspectCycleUnitWeek:
      s = cycle * 86400 * 7
   case constvar.InspectCycleUnitMonth:
      s = cycle * 86400 * 30
   case constvar.InspectCycleUnitDay:
      s = cycle * 86400
   }
   return s
}