mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-26 12:08:50 +00:00
start work with scheduler and remove redundant regexes from CronDateTime
This commit is contained in:
parent
6f48b4f29a
commit
e5e4770346
@ -1,13 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.krontab
|
package com.github.insanusmokrassar.krontab
|
||||||
|
|
||||||
import com.soywiz.klock.*
|
import com.github.insanusmokrassar.krontab.utils.*
|
||||||
import com.github.insanusmokrassar.krontab.utils.clamp
|
import com.github.insanusmokrassar.krontab.utils.clamp
|
||||||
|
import com.github.insanusmokrassar.krontab.utils.dayOfMonthRange
|
||||||
private val incomeMonthRange = 0 .. 11
|
import com.github.insanusmokrassar.krontab.utils.monthRange
|
||||||
private val incomeDayOfMonthRange = 0 .. 31
|
import com.soywiz.klock.*
|
||||||
private val incomeHourRange = 0 .. 23
|
|
||||||
private val incomeMinuteRange = 0 .. 59
|
|
||||||
private val incomeSecondRange = 0 .. 59
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [month] 0-11
|
* [month] 0-11
|
||||||
@ -24,11 +21,11 @@ data class CronDateTime(
|
|||||||
val seconds: Byte? = null
|
val seconds: Byte? = null
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
check(month ?.let { it in incomeMonthRange } ?: true)
|
check(month ?.let { it in monthRange } ?: true)
|
||||||
check(dayOfMonth ?.let { it in incomeDayOfMonthRange } ?: true)
|
check(dayOfMonth ?.let { it in dayOfMonthRange } ?: true)
|
||||||
check(hours?.let { it in incomeHourRange } ?: true)
|
check(hours?.let { it in hoursRange } ?: true)
|
||||||
check(minutes?.let { it in incomeMinuteRange } ?: true)
|
check(minutes?.let { it in minutesRange } ?: true)
|
||||||
check(seconds?.let { it in incomeSecondRange } ?: true)
|
check(seconds?.let { it in secondsRange } ?: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
||||||
@ -41,11 +38,11 @@ data class CronDateTime(
|
|||||||
minutes: Int? = null,
|
minutes: Int? = null,
|
||||||
seconds: Int? = null
|
seconds: Int? = null
|
||||||
) = CronDateTime(
|
) = CronDateTime(
|
||||||
month ?.clamp(incomeMonthRange) ?.toByte(),
|
month ?.clamp(monthRange) ?.toByte(),
|
||||||
dayOfMonth ?.clamp(incomeDayOfMonthRange) ?.toByte(),
|
dayOfMonth ?.clamp(dayOfMonthRange) ?.toByte(),
|
||||||
hours ?.clamp(incomeHourRange) ?.toByte(),
|
hours ?.clamp(hoursRange) ?.toByte(),
|
||||||
minutes ?.clamp(incomeMinuteRange) ?.toByte(),
|
minutes ?.clamp(minutesRange) ?.toByte(),
|
||||||
seconds ?.clamp(incomeSecondRange) ?.toByte()
|
seconds ?.clamp(secondsRange) ?.toByte()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ internal val minutesRegex = Regex("[*]|((${minutesOrSecondsNumberRegex.pattern})
|
|||||||
internal val secondsRegex = minutesRegex
|
internal val secondsRegex = minutesRegex
|
||||||
|
|
||||||
internal val monthRange = 0 .. 11
|
internal val monthRange = 0 .. 11
|
||||||
internal val dayOfMonthRange = 0 .. 31
|
internal val dayOfMonthRange = 0 .. 30
|
||||||
internal val hoursRange = 0 .. 23
|
internal val hoursRange = 0 .. 23
|
||||||
internal val minutesRange = 0 .. 59
|
internal val minutesRange = 0 .. 59
|
||||||
internal val secondsRange = minutesRange
|
internal val secondsRange = minutesRange
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package com.github.insanusmokrassar.krontab
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user