mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 08:13:54 +00:00
fix of #27
This commit is contained in:
parent
f163a64964
commit
58f30aef15
@ -57,13 +57,13 @@ typealias KrontabTemplate = String
|
||||
* * "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 * * * 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 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 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 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 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 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 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" 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 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 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 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 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 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 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
|
||||
* returned [CronDateTimeScheduler]. In case when offset parameter there is in [incoming] [KrontabTemplate] will be used
|
||||
|
@ -8,7 +8,7 @@ import dev.inmo.krontab.KronScheduler
|
||||
* @param daysOfWeek 0-6
|
||||
* @param years any int
|
||||
* @param months 0-11
|
||||
* @param daysOfMonth 0-31
|
||||
* @param daysOfMonth 0-30
|
||||
* @param hours 0-23
|
||||
* @param minutes 0-59
|
||||
* @param seconds 0-59
|
||||
|
@ -103,12 +103,13 @@ internal fun NearDateTimeCalculatorDays(
|
||||
times,
|
||||
{ it.dayOfMonth.toByte() },
|
||||
{ dateTime, newOne ->
|
||||
(if (newOne < dateTime.dayOfMonth) {
|
||||
val dateTime = (if (newOne < dateTime.dayOfMonth) {
|
||||
dateTime.plus(1.months)
|
||||
} else {
|
||||
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,
|
||||
minute = 0,
|
||||
second = 0,
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user