File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -163,11 +163,16 @@ func (s Schedule) Next(t time.Time) time.Time {
163
163
// However, due to minor implementation imprecision, it is interpreted as
164
164
// a range from 08:59:00 to 18:58:59, Monday through Friday.
165
165
func (s Schedule ) IsWithinRange (t time.Time ) bool {
166
- // Get the next scheduled time
167
- next := s .Next (t )
168
-
169
- // If the next time is more than a minute away, we're not within range
170
- return next .Sub (t ) <= time .Minute
166
+ // Truncate to the beginning of the current minute.
167
+ currentMinute := t .Truncate (time .Minute )
168
+
169
+ // Go back 1 second from the current minute to find what the next scheduled time would be.
170
+ justBefore := currentMinute .Add (- time .Second )
171
+ next := s .Next (justBefore )
172
+
173
+ // If the next scheduled time is exactly at the current minute,
174
+ // then we are within the range.
175
+ return next .Equal (currentMinute )
171
176
}
172
177
173
178
var (
You can’t perform that action at this time.
0 commit comments