Skip to content

Commit

Permalink
Fix for invalid day of week max check (openhab#1986)
Browse files Browse the repository at this point in the history
Closes openhab#1813

Signed-off-by: Hilbrand Bouwkamp <[email protected]>
GitOrigin-RevId: df20138
  • Loading branch information
Hilbrand authored and splatch committed Jul 11, 2023
1 parent 21483c8 commit 68567bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,6 @@ private Checker parseSub(final String cronExpression, final ChronoField chronoFi
final String[] increments = sub.split("/");
final int[] range = parseRange(cronExpression, chronoField, increments[0], min, max, names);

if (chronoField == ChronoField.DAY_OF_WEEK) {
range[0] = range[0] - 1;
range[1] = range[1] - 1;
}

if (increments.length == 2) {
// we had a / expression
final int increment = parseInt(cronExpression, chronoField, increments[1]);
Expand Down Expand Up @@ -488,7 +483,7 @@ private int parseInt(final String cronExpression, final ChronoField chronoField,
if (nameIndex == null) {
return parseInt(cronExpression, chronoField, name);
} else {
return min + nameIndex;
return min + nameIndex - (chronoField == ChronoField.DAY_OF_WEEK ? 1 : 0);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public static Collection<Object[]> arguments() {
{ JAN_1ST_2015, "0 0 0 ? * SUN", new String[] { "2015-01-04T00:00" } },
{ JAN_1ST_2015, "0 0 0 ? * SUN-MON",
new String[] { "2015-01-04T00:00", "2015-01-05T00:00", "2015-01-11T00:00" } },
{ JAN_1ST_2015, "0 0 0 ? * MON-SUN",
new String[] { "2015-01-02T00:00", "2015-01-03T00:00", "2015-01-04T00:00" } },
{ JAN_1ST_2000, "14-02/2 * * * * *",
new String[] { "2000-01-01T00:00:02", "2000-01-01T00:00:14", "2000-01-01T00:00:16",
"2000-01-01T00:00:18" } },
Expand Down

0 comments on commit 68567bf

Please sign in to comment.