in mysql/mysql.go [402:428]
func noKillsSince(days int, now time.Time, endHour int, loc *time.Location) (time.Time, error) {
if days < 0 {
return time.Time{}, errors.Errorf("noKillsSince passed illegal input: days=%d", days)
}
oneDay := time.Hour * 24
// Tail-recursive helper function reads clearer than writing a
// traditional loop
//
// It expects a time localized to the zone associated with endHour because
// workday and year-month-day values depend on the local timezone
var helper func(N int, tInLoc time.Time) time.Time
helper = func(N int, tInLoc time.Time) time.Time {
switch {
case !cal.IsWorkday(tInLoc):
return helper(N, tInLoc.Add(-oneDay))
case N == 0:
return time.Date(tInLoc.Year(), tInLoc.Month(), tInLoc.Day(), endHour, 0, 0, 0, loc).UTC()
default:
return helper(N-1, tInLoc.Add(-oneDay))
}
}
return helper(days, now.In(loc)), nil
}