This commit is contained in:
InsanusMokrassar 2022-06-15 12:40:03 +06:00
parent f163a64964
commit 58f30aef15
4 changed files with 26 additions and 11 deletions

View File

@ -57,13 +57,13 @@ typealias KrontabTemplate = String
* * "0/5,L * * * *" for every five seconds triggering and on 59 second * * "0/5,L * * * *" for every five seconds triggering and on 59 second
* * "0/15 30 * * *" for every 15th seconds in a half of each hour * * "0/15 30 * * *" for every 15th seconds in a half of each hour
* * "0/15 30 * * * 500ms" for every 15th seconds in a half of each hour when milliseconds equal to 500 * * "0/15 30 * * * 500ms" for every 15th seconds in a half of each hour when milliseconds equal to 500
* * "1 2 3 F,4,L 5" for triggering in near first second of second minute of third hour of fourth day of may * * "1 2 3 F,4,L 5" for triggering in near first second of second minute of third hour of first, fifth and last days of may
* * "1 2 3 F,4,L 5 60o" for triggering in near first second of second minute of third hour of fourth day of may with timezone UTC+01:00 * * "1 2 3 F,4,L 5 60o" for triggering in near first second of second minute of third hour of first, fifth and last days of may with timezone UTC+01:00
* * "1 2 3 F,4,L 5 60o 0-2w" for triggering in near first second of second minute of third hour of fourth day of may in case if it will be in Sunday-Tuesday week days with timezone UTC+01:00 * * "1 2 3 F,4,L 5 60o 0-2w" for triggering in near first second of second minute of third hour of first, fifth and last days of may in case if it will be in Sunday-Tuesday week days with timezone UTC+01:00
* * "1 2 3 F,4,L 5 2021" for triggering in near first second of second minute of third hour of fourth day of may of 2021st year * * "1 2 3 F,4,L 5 2021" for triggering in near first second of second minute of third hour of first, fifth and last days of may of 2021st year
* * "1 2 3 F,4,L 5 2021 60o" for triggering in near first second of second minute of third hour of fourth day of may of 2021st year with timezone UTC+01:00 * * "1 2 3 F,4,L 5 2021 60o" for triggering in near first second of second minute of third hour of first, fifth and last days of may of 2021st year with timezone UTC+01:00
* * "1 2 3 F,4,L 5 2021 60o 0-2w" for triggering in near first second of second minute of third hour of fourth day of may of 2021st year if it will be in Sunday-Tuesday week days with timezone UTC+01:00 * * "1 2 3 F,4,L 5 2021 60o 0-2w" for triggering in near first second of second minute of third hour of first, fifth and last days of may of 2021st year if it will be in Sunday-Tuesday week days with timezone UTC+01:00
* * "1 2 3 F,4,L 5 2021 60o 0-2w 500ms" for triggering in near first second of second minute of third hour of fourth day of may of 2021st year if it will be in Sunday-Tuesday week days with timezone UTC+01:00 when milliseconds will be equal to 500 * * "1 2 3 F,4,L 5 2021 60o 0-2w 500ms" for triggering in near first second of second minute of third hour of first, fifth and last days of may of 2021st year if it will be in Sunday-Tuesday week days with timezone UTC+01:00 when milliseconds will be equal to 500
* *
* @return In case when offset parameter is absent in [incoming] will be used [createSimpleScheduler] method and * @return In case when offset parameter is absent in [incoming] will be used [createSimpleScheduler] method and
* returned [CronDateTimeScheduler]. In case when offset parameter there is in [incoming] [KrontabTemplate] will be used * returned [CronDateTimeScheduler]. In case when offset parameter there is in [incoming] [KrontabTemplate] will be used

View File

@ -8,7 +8,7 @@ import dev.inmo.krontab.KronScheduler
* @param daysOfWeek 0-6 * @param daysOfWeek 0-6
* @param years any int * @param years any int
* @param months 0-11 * @param months 0-11
* @param daysOfMonth 0-31 * @param daysOfMonth 0-30
* @param hours 0-23 * @param hours 0-23
* @param minutes 0-59 * @param minutes 0-59
* @param seconds 0-59 * @param seconds 0-59

View File

@ -103,12 +103,13 @@ internal fun NearDateTimeCalculatorDays(
times, times,
{ it.dayOfMonth.toByte() }, { it.dayOfMonth.toByte() },
{ dateTime, newOne -> { dateTime, newOne ->
(if (newOne < dateTime.dayOfMonth) { val dateTime = (if (newOne < dateTime.dayOfMonth) {
dateTime.plus(1.months) dateTime.plus(1.months)
} else { } else {
dateTime dateTime
}).copy( })
dayOfMonth = min(dateTime.month.days(dateTime.year), newOne.toInt() + 1), // index1 dateTime.copy(
dayOfMonth = min(dateTime.month.days(dateTime.year) - 1, newOne.toInt()), // index1
hour = 0, hour = 0,
minute = 0, minute = 0,
second = 0, second = 0,

View File

@ -0,0 +1,14 @@
package dev.inmo.krontab.utils
import dev.inmo.krontab.buildSchedule
import kotlin.test.Test
import kotlin.test.assertNotNull
class InfinityLoopCheckTest {
@Test
fun absenceOfInfinityLoopCheckTest() {
runTest {
assertNotNull(buildSchedule("0 0 0 1 *").next())
}
}
}