add day of week

This commit is contained in:
兔子 2022-12-13 19:37:51 +08:00
parent a8f7de6042
commit 4ea575ecf2

View File

@ -77,3 +77,11 @@ func WithStaticDate(t time.Time) TimerOptions {
option.date = t
}
}
func NextDayOfWeek(date time.Time, weekDay int) time.Time {
sub := weekDay - int(date.Weekday())
if sub <= 0 {
sub += 7
}
return date.Add(time.Hour * 24 * time.Duration(sub))
}