fix 定时器周变更事件

This commit is contained in:
sk 2025-01-20 00:03:52 +08:00
parent 0edc943ede
commit b98c74c983
2 changed files with 9 additions and 5 deletions

View File

@ -122,9 +122,9 @@ func (this *ClockMgr) Update() {
this.LastDay = day
this.fireDayEvent()
week := GetWeekStartTs(tNow.Unix())
if week != int64(this.LastWeek) {
this.LastWeek = int(week)
_, week := tNow.ISOWeek()
if week != this.LastWeek {
this.LastWeek = week
this.fireWeekEvent()
}

View File

@ -76,8 +76,12 @@ func InSameWeek(tNow, tPre time.Time) bool {
if tPre.IsZero() {
return true
}
if GetWeekStartTs(tNow.Unix()) == GetWeekStartTs(tPre.Unix()) {
y1, w1 := tNow.ISOWeek()
y2, w2 := tPre.ISOWeek()
if y1 != y2 {
return false
}
if w1 == w2 {
return true
}
return false