Skip to content

Commit

Permalink
Merge pull request #161 from starkandwayne/weekly-bug
Browse files Browse the repository at this point in the history
Proper Weekly Re-scheduling
  • Loading branch information
dennisjbell committed May 16, 2016
2 parents 3071f1e + 17a17dd commit 8f5018f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion timespec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *Spec) Next(t time.Time) (time.Time, error) {
for target.Weekday() != s.DayOfWeek {
target = offsetM(target, 1440)
}
if target.Before(t) {
if target.Before(t) || target.Equal(t) {
target = offsetM(target, 7*1440)
}
return target, nil
Expand Down
11 changes: 11 additions & 0 deletions timespec/timespec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ var _ = Describe("Timespec", func() {
*/

It("handles the next timestamp being in exactly one week", func() {
spec := &Spec{
Interval: Weekly,
DayOfWeek: time.Tuesday,
TimeOfDay: inMinutes(11, 15),
}

Ω(spec.Next(now)).Should(Equal(
time.Date(1991, 8, 13, 11, 15, 00, 00, tz)))
})

It("handles the next timestamp being later in the week", func() {
spec := &Spec{
Interval: Weekly,
Expand Down

0 comments on commit 8f5018f

Please sign in to comment.