diff --git a/common/time.go b/common/time.go index 64f93df..2afb753 100644 --- a/common/time.go +++ b/common/time.go @@ -76,17 +76,15 @@ func InSameWeek(tNow, tPre time.Time) bool { return true } - preYear, preWeek := tPre.ISOWeek() - nowYear, nowWeek := tNow.ISOWeek() - if preYear == nowYear && preWeek == nowWeek { + if GetWeekStartTs(tNow.Unix()) == GetWeekStartTs(tPre.Unix()) { return true } return false } func TsInSameWeek(tsNow, tsPre int64) bool { - tNow := time.Unix(tsNow, 0) - tPre := time.Unix(tsPre, 0) + tNow := time.Unix(tsNow, 0).Local() + tPre := time.Unix(tsPre, 0).Local() return InSameWeek(tNow, tPre) } @@ -144,22 +142,16 @@ func InTimeRange(beginHour, beginMinute, endHour, endMinute, checkHour, checkMin return beginTime <= checkTime && checkTime <= endTime } -func GetWeekTimestamp() []int64 { - now := time.Now().Local() - year, month, day := now.Date() - today := time.Date(year, month, day, 0, 0, 0, 0, time.Local) - // 本周起始日期(周日) - st := today.AddDate(0, 0, -int(today.Weekday())).Unix() - et := today.AddDate(0, 0, 7-int(today.Weekday())).Unix() - return []int64{st, et} -} - +// GetWeekStartTs 获取本周开始的时间戳,周一为周的开始 func GetWeekStartTs(ts int64) int64 { now := time.Unix(ts, 0).Local() year, month, day := now.Date() today := time.Date(year, month, day, 0, 0, 0, 0, time.Local) - // 本周起始日期(周日) - st := today.AddDate(0, 0, -int(today.Weekday())).Unix() + n := today.Weekday() + if today.Weekday() == 0 { + n = 7 + } + st := today.AddDate(0, 0, -int(n-1)).Unix() return st } diff --git a/dbproxy/svc/l_invitescore.go b/dbproxy/svc/l_invitescore.go index f094962..7b29c11 100644 --- a/dbproxy/svc/l_invitescore.go +++ b/dbproxy/svc/l_invitescore.go @@ -260,7 +260,7 @@ func (b *BindScoreSvc) GetInviteList(req *model.InviteLisArgs, ret *model.Invite now := time.Now().Local() for _, v := range res { - if !common.InSameWeek(now, v.IScoreTs) { + if !common.InSameWeek(now, v.IScoreTs.Local()) { v.IScore = 0 } roleId := common.DefaultRoleId diff --git a/worldsrv/player.go b/worldsrv/player.go index faf0d98..515f5f5 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -2269,6 +2269,7 @@ func (this *Player) OnMonthTimer() { } func (this *Player) OnWeekTimer() { + logger.Logger.Tracef("OnWeekTimer %v", time.Now()) //判断是否一天即可过滤0点多次切换 if common.InSameDayNoZero(time.Now().Local(), this.lastOnWeekChange) { return