File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ func (evaluator BaseTimeRangeExpressionEvaluator) getDurationForHourMinute() tim
3232
3333func (evaluator BaseTimeRangeExpressionEvaluator ) getDurationBetweenWeekdays () time.Duration {
3434 days := calculateDaysBetweenWeekdays (int (evaluator .TimeRange .WeekdayFrom ), int (evaluator .TimeRange .WeekdayTo ))
35+ // When weekdayFrom == weekdayTo, days is 0. If the to-time is not after the from-time the window
36+ // would collapse to a zero/negative duration, which stalls the next-window search (infinite loop).
37+ // Treat such a same-weekday range as spanning the full week instead.
38+ if days == 0 && isToBeforeFrom (evaluator .TimeRange .HourMinuteFrom , evaluator .TimeRange .HourMinuteTo ) {
39+ days = daysInWeek
40+ }
3541 fromDateTime := constructDateTime (evaluator .TimeRange .HourMinuteFrom , 0 )
3642 toDateTime := constructDateTime (evaluator .TimeRange .HourMinuteTo , days )
3743 return toDateTime .Sub (fromDateTime )
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ type TimeRange struct {
5555// random values for for understanding HH:MM format
5656const hourMinuteFormat = "15:04"
5757
58+ const daysInWeek = 7
59+
5860type Frequency string
5961
6062const (
You can’t perform that action at this time.
0 commit comments