新增通用方法
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type timeMod struct {
|
type timeMod struct {
|
||||||
@@ -128,3 +129,26 @@ func (m *timeMod) ExcelTime2Time(excelTime string) time.Time {
|
|||||||
timeNew, _ := time.ParseInLocation(layout, excelTime, time.Local)
|
timeNew, _ := time.ParseInLocation(layout, excelTime, time.Local)
|
||||||
return timeNew
|
return timeNew
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 指定时刻刷新
|
||||||
|
// 判断当前是否可领取
|
||||||
|
// createdTime 刷新时刻
|
||||||
|
// lastRwdTime 上次领取时间
|
||||||
|
// now 当前时间
|
||||||
|
func (m *timeMod) CheckIsBeRwd(createdTime, lastRwdTime time.Time, _now ...time.Time) bool {
|
||||||
|
now := time.Now()
|
||||||
|
if len(_now) > 0 {
|
||||||
|
now = _now[0]
|
||||||
|
}
|
||||||
|
//今天的刷新时间
|
||||||
|
refreshToday := time.Date(now.Year(), now.Month(), now.Day(),
|
||||||
|
createdTime.Hour(), createdTime.Minute(), createdTime.Second(),
|
||||||
|
0, createdTime.Location())
|
||||||
|
// 如果今天还没到刷新时间,则刷新时间应是昨天
|
||||||
|
if now.Before(refreshToday) {
|
||||||
|
refreshToday = refreshToday.AddDate(0, 0, -1)
|
||||||
|
}
|
||||||
|
// 判断上次领取时间是否在刷新时间之前
|
||||||
|
// 如果是,则说明还没领过,可以领取
|
||||||
|
return lastRwdTime.Before(refreshToday)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user