diff --git a/cronexpr_next.go b/cronexpr_next.go index 169c900..1d627b4 100644 --- a/cronexpr_next.go +++ b/cronexpr_next.go @@ -236,7 +236,7 @@ func (expr *Expression) calculateActualDaysOfMonth(year, month int) []int { // offset : (7 - day_of_week_of_1st_day_of_month) // target : 1 + (7 * week_of_month) + (offset + day_of_week) % 7 for v := range expr.daysOfWeek { - w := dowNormalizedOffsets[offset%7+v] + w := dowNormalizedOffsets[(offset+v)%7] actualDaysOfMonthMap[w[0]] = true actualDaysOfMonthMap[w[1]] = true actualDaysOfMonthMap[w[2]] = true diff --git a/cronexpr_test.go b/cronexpr_test.go index 32467fb..3692227 100644 --- a/cronexpr_test.go +++ b/cronexpr_test.go @@ -106,8 +106,17 @@ var crontests = []crontest{ {"2013-12-30 00:30:00", "Mon 2014-01-06 00:00"}, }, }, + { + "0 0 * * friday", + "Mon 2006-01-02 15:04", + []crontimes{ + {"2013-01-01 00:00:00", "Fri 2013-01-04 00:00"}, + {"2013-01-28 00:00:00", "Fri 2013-02-01 00:00"}, + {"2013-12-30 00:30:00", "Fri 2014-01-03 00:00"}, + }, + }, - // Specific weekdays of week + // Specific days of week { "0 0 * * 6#5", "Mon 2006-01-02 15:04",