add day of week

master
兔子 2 years ago
parent a8f7de6042
commit 4ea575ecf2

@ -77,3 +77,11 @@ func WithStaticDate(t time.Time) TimerOptions {
option.date = t 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))
}

Loading…
Cancel
Save