Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ private static ValueRange parseRange(String value, Type type) {
int max = Integer.parseInt(value, hyphenPos + 1, value.length(), 10);
min = type.checkValidValue(min);
max = type.checkValidValue(max);
if (type == Type.DAY_OF_WEEK && min == 7) {
// If used as a minimum in a range, Sunday means 0 (not 7)
if (type == Type.DAY_OF_WEEK && min == 7 && max != 7) {
// If used as a minimum in a range, Sunday means 0 (not 7),
// unless the range also ends with Sunday, as in "SUN-SUN"
min = 0;
}
return ValueRange.of(min, max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void parse() {
assertThat(BitsCronField.parseDaysOfWeek("0")).has(set(7, 7)).has(clearRange(0, 6));
assertThat(BitsCronField.parseDaysOfWeek("7-5")).has(clear(0)).has(setRange(1, 5))
.has(clear(6)).has(set(7));
assertThat(BitsCronField.parseDaysOfWeek("7-7")).has(clearRange(0, 6)).has(set(7));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,25 @@ void sundayToFriday() {
assertThat(actual.getDayOfWeek()).isEqualTo(SUNDAY);
}

@Test
void sundayToSunday() {
CronExpression expression = CronExpression.parse("0 0 0 ? * SUN-SUN");

LocalDateTime last = LocalDateTime.of(2021, 2, 25, 15, 0);
LocalDateTime expected = LocalDateTime.of(2021, 2, 28, 0, 0);
LocalDateTime actual = expression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
assertThat(actual.getDayOfWeek()).isEqualTo(SUNDAY);

last = actual;
expected = LocalDateTime.of(2021, 3, 7, 0, 0);
actual = expression.next(last);
assertThat(actual).isNotNull();
assertThat(actual).isEqualTo(expected);
assertThat(actual.getDayOfWeek()).isEqualTo(SUNDAY);
}

@Test
void daylightSaving() {
CronExpression cronExpression = CronExpression.parse("0 0 9 * * *");
Expand Down