#6: added simple test to avoid work

This commit is contained in:
gorhill 2013-09-10 16:09:51 -04:00
parent 2fc5c1e285
commit 0e96f12377
1 changed files with 10 additions and 2 deletions

View File

@ -183,7 +183,14 @@ func (expr *Expression) calculateActualDaysOfMonth(year, month int) []int {
// "fields - day of month, and day of week. If both fields are // "fields - day of month, and day of week. If both fields are
// "restricted (ie, aren't *), the command will be run when // "restricted (ie, aren't *), the command will be run when
// "either field matches the current time" // "either field matches the current time"
if expr.daysOfMonthRestricted || expr.daysOfWeekRestricted == false {
// If both fields are not restricted, all days of the month are a hit
if expr.daysOfMonthRestricted == false && expr.daysOfWeekRestricted == false {
return genericDefaultList[1 : lastDayOfMonth.Day()+1]
}
// day-of-month != `*`
if expr.daysOfMonthRestricted {
// Last day of month // Last day of month
if expr.lastDayOfMonth { if expr.lastDayOfMonth {
actualDaysOfMonthMap[lastDayOfMonth.Day()] = true actualDaysOfMonthMap[lastDayOfMonth.Day()] = true
@ -209,6 +216,7 @@ func (expr *Expression) calculateActualDaysOfMonth(year, month int) []int {
} }
} }
// day-of-week != `*`
if expr.daysOfWeekRestricted { if expr.daysOfWeekRestricted {
// How far first sunday is from first day of month // How far first sunday is from first day of month
offset := 7 - int(firstDayOfMonth.Weekday()) offset := 7 - int(firstDayOfMonth.Weekday())