File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const (
2828 WeekDaysNotPresent ErrorMessage = "weekdays, must be present for Weekly frequency"
2929 WeekDayFromOrToNotPresent ErrorMessage = "weekdayFrom, must be present for WeeklyRange frequency"
3030 DayFromOrToNotPresent ErrorMessage = "dayFrom, dayTo, must be present for Monthly frequency"
31- ToBeforeFrom ErrorMessage = "Invalid value of hourMinuteFrom or hourMinuteTo for same day ,hourMinuteFrom >hourMinuteTo"
31+ ToBeforeFrom ErrorMessage = "Invalid value of hourMinuteFrom or hourMinuteTo for same day ,hourMinuteFrom > hourMinuteTo"
3232 BothLessThanZeroAndFromGreaterThanTo ErrorMessage = "invalid value of DayFrom or DayTo,DayFrom and DayTo is less than zero and dayFrom > dayTo"
3333 DayFromOrToNotValid ErrorMessage = "invalid value of dayFrom or dayTo"
3434 InvalidHourMinuteForWeeklyAndDaily ErrorMessage = "HourMinuteFrom should be less than HourMinuteTo in daily or weekly Frequency"
Original file line number Diff line number Diff line change @@ -32,12 +32,6 @@ 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- }
4135 fromDateTime := constructDateTime (evaluator .TimeRange .HourMinuteFrom , 0 )
4236 toDateTime := constructDateTime (evaluator .TimeRange .HourMinuteTo , days )
4337 return toDateTime .Sub (fromDateTime )
Original file line number Diff line number Diff line change @@ -55,8 +55,6 @@ type TimeRange struct {
5555// random values for for understanding HH:MM format
5656const hourMinuteFormat = "15:04"
5757
58- const daysInWeek = 7
59-
6058type Frequency string
6159
6260const (
Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ func (tr TimeRange) ValidateTimeRange() error {
8686 if (tr .WeekdayFrom < 0 || tr .WeekdayFrom > 6 ) || (tr .WeekdayTo < 0 || tr .WeekdayTo > 6 ) {
8787 return errors .New (string (WeekDayOutsideRange ))
8888 }
89+ // Same weekday with a non-positive intra-day span collapses the window to zero/negative
90+ // duration, which stalls the next-window search. Reject it (mirrors the Monthly check).
91+ if tr .WeekdayFrom == tr .WeekdayTo && isToBeforeFrom (tr .HourMinuteFrom , tr .HourMinuteTo ) {
92+ return errors .New (string (ToBeforeFrom ))
93+ }
8994 case Monthly :
9095 if tr .DayFrom == 0 || tr .DayTo == 0 {
9196 return errors .New (string (DayFromOrToNotPresent ))
You can’t perform that action at this time.
0 commit comments