Skip to content

Commit 0798dc2

Browse files
author
penglj
committedMay 9, 2022
origin modules not active,thanks robfig#402
1 parent 69c152c commit 0798dc2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎constantdelay.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func Every(duration time.Duration) ConstantDelaySchedule {
1919
duration = time.Second
2020
}
2121
return ConstantDelaySchedule{
22-
Delay: duration - time.Duration(duration.Nanoseconds())%time.Second,
22+
Delay: duration.Truncate(time.Second),
2323
}
2424
}
2525

@@ -42,7 +42,7 @@ func (schedule ConstantDelaySchedule) Next(t time.Time) time.Time {
4242
t = schedule.startAt.Add((t.Sub(schedule.startAt) / schedule.Delay) * (schedule.Delay))
4343
}
4444

45-
return t.Add(schedule.Delay - time.Duration(t.Nanosecond())*time.Nanosecond)
45+
return t.Add(schedule.Delay).Truncate(time.Second)
4646
}
4747

4848
func (schedule ConstantDelaySchedule) IsOnce() bool {

0 commit comments

Comments
 (0)
Please sign in to comment.