diff --git a/.gitignore b/.gitignore index eb5a316..c507849 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +.idea diff --git a/src/main/java/com/github/shyiko/skedule/internal/ScheduleImpl.kt b/src/main/java/com/github/shyiko/skedule/internal/ScheduleImpl.kt index 16eca13..560280d 100644 --- a/src/main/java/com/github/shyiko/skedule/internal/ScheduleImpl.kt +++ b/src/main/java/com/github/shyiko/skedule/internal/ScheduleImpl.kt @@ -1,19 +1,11 @@ package com.github.shyiko.skedule.internal -import com.github.shyiko.skedule.InvalidScheduleException -import com.github.shyiko.skedule.Schedule -import java.lang.AssertionError -import java.time.DayOfWeek -import java.time.Duration -import java.time.LocalTime -import java.time.Month -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatterBuilder -import java.time.temporal.ChronoField -import java.time.temporal.ChronoUnit -import java.time.temporal.TemporalAdjusters -import java.util.EnumSet -import java.util.concurrent.TimeUnit +import com.github.shyiko.skedule.* +import java.time.* +import java.time.format.* +import java.time.temporal.* +import java.util.* +import java.util.concurrent.* internal object ScheduleImpl { @@ -168,7 +160,7 @@ internal object ScheduleImpl { rawOrdinal.split(',').flatMapTo(mutableSetOf()) { if (it.contains('-')) parseOrdinalRange(it, 1, 31) else setOf(parseOrdinal(it)) }, - months = if (month == "") MONTH_ALL else + months = if (month == "month") MONTH_ALL else EnumSet.copyOf(month.split(',').flatMap { if (it.contains('-')) parseMonthRange(it) else setOf(parseMonth(it)) }), diff --git a/src/test/java/com/github/shyiko/skedule/ScheduleTest.kt b/src/test/java/com/github/shyiko/skedule/ScheduleTest.kt index 3a5f9f8..0386cca 100644 --- a/src/test/java/com/github/shyiko/skedule/ScheduleTest.kt +++ b/src/test/java/com/github/shyiko/skedule/ScheduleTest.kt @@ -1,12 +1,9 @@ package com.github.shyiko.skedule -import org.assertj.core.api.Assertions.assertThat -import org.testng.annotations.Test -import java.time.DayOfWeek -import java.time.LocalTime -import java.time.Month -import java.time.ZonedDateTime -import java.time.format.DateTimeFormatter +import org.assertj.core.api.Assertions.* +import org.testng.annotations.* +import java.time.* +import java.time.format.* class ScheduleTest { @@ -213,6 +210,21 @@ class ScheduleTest { )) } + @Test + fun testEveryMonth() { + assertThat( + iterateOverSchedule( + "1st monday of month 09:00", + ZonedDateTime.parse("2018-01-01T00:00:00.007Z"), + skipFirstIfSame = false + ) + ).isEqualTo(listOf( + "2018-01-01T09:00:00Z", + "2018-02-05T09:00:00Z", + "2018-03-05T09:00:00Z" + )) + } + @Test fun testHourAlias() { assertThat(