diff --git a/common-lib/timeRangeLib/constant.go b/common-lib/timeRangeLib/constant.go index e4ed49d03..e3ebc3306 100644 --- a/common-lib/timeRangeLib/constant.go +++ b/common-lib/timeRangeLib/constant.go @@ -28,7 +28,7 @@ const ( WeekDaysNotPresent ErrorMessage = "weekdays, must be present for Weekly frequency" WeekDayFromOrToNotPresent ErrorMessage = "weekdayFrom, must be present for WeeklyRange frequency" DayFromOrToNotPresent ErrorMessage = "dayFrom, dayTo, must be present for Monthly frequency" - ToBeforeFrom ErrorMessage = "Invalid value of hourMinuteFrom or hourMinuteTo for same day ,hourMinuteFrom >hourMinuteTo" + ToBeforeFrom ErrorMessage = "Invalid value of hourMinuteFrom or hourMinuteTo for same day ,hourMinuteFrom > hourMinuteTo" BothLessThanZeroAndFromGreaterThanTo ErrorMessage = "invalid value of DayFrom or DayTo,DayFrom and DayTo is less than zero and dayFrom > dayTo" DayFromOrToNotValid ErrorMessage = "invalid value of dayFrom or dayTo" InvalidHourMinuteForWeeklyAndDaily ErrorMessage = "HourMinuteFrom should be less than HourMinuteTo in daily or weekly Frequency" diff --git a/common-lib/timeRangeLib/validator.go b/common-lib/timeRangeLib/validator.go index 94bb1d3f0..9f0c31be0 100644 --- a/common-lib/timeRangeLib/validator.go +++ b/common-lib/timeRangeLib/validator.go @@ -86,6 +86,11 @@ func (tr TimeRange) ValidateTimeRange() error { if (tr.WeekdayFrom < 0 || tr.WeekdayFrom > 6) || (tr.WeekdayTo < 0 || tr.WeekdayTo > 6) { return errors.New(string(WeekDayOutsideRange)) } + // Same weekday with a non-positive intra-day span collapses the window to zero/negative + // duration, which stalls the next-window search. Reject it (mirrors the Monthly check). + if tr.WeekdayFrom == tr.WeekdayTo && isToBeforeFrom(tr.HourMinuteFrom, tr.HourMinuteTo) { + return errors.New(string(ToBeforeFrom)) + } case Monthly: if tr.DayFrom == 0 || tr.DayTo == 0 { return errors.New(string(DayFromOrToNotPresent))