Skip to content

Commit

Permalink
fix: 修复 times.GetCurrWeekDate 和 times.GetLastWeekDate 在 week 参数与今日 we…
Browse files Browse the repository at this point in the history
…ek 相同的情况下,会多获取到一周的问题
  • Loading branch information
kercylan98 committed Feb 4, 2024
1 parent f8e368a commit 902dada
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/times/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func GetCurrWeekDate(now time.Time, week time.Weekday) time.Time {
w := int(week)
monday := GetMondayZero(now)
var curr time.Time
if WeekDay(now) > w {
if WeekDay(now) >= w {
curr = monday.AddDate(0, 0, w-1)
} else {
curr = monday.AddDate(0, 0, w-1)
Expand All @@ -34,7 +34,7 @@ func GetLastWeekDate(now time.Time, week time.Weekday) time.Time {
w := int(week)
monday := GetMondayZero(now)
var last time.Time
if WeekDay(now) > w {
if WeekDay(now) >= w {
last = monday.AddDate(0, 0, -(7 - w + 1))
} else {
last = monday.AddDate(0, 0, -(7 - w + 1))
Expand Down

0 comments on commit 902dada

Please sign in to comment.