mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-29 13:38:50 +00:00
refactor of CronDateTime
This commit is contained in:
parent
0178ac140a
commit
1f971117bd
@ -19,11 +19,11 @@ internal data class CronDateTime(
|
|||||||
val seconds: Byte? = null
|
val seconds: Byte? = null
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
check(month ?.let { it in com.insanusmokrassar.krontab.internal.monthRange } ?: true)
|
check(month ?.let { it in monthRange } ?: true)
|
||||||
check(dayOfMonth ?.let { it in com.insanusmokrassar.krontab.internal.dayOfMonthRange } ?: true)
|
check(dayOfMonth ?.let { it in dayOfMonthRange } ?: true)
|
||||||
check(hours?.let { it in com.insanusmokrassar.krontab.internal.hoursRange } ?: true)
|
check(hours?.let { it in hoursRange } ?: true)
|
||||||
check(minutes?.let { it in com.insanusmokrassar.krontab.internal.minutesRange } ?: true)
|
check(minutes?.let { it in minutesRange } ?: true)
|
||||||
check(seconds?.let { it in com.insanusmokrassar.krontab.internal.secondsRange } ?: true)
|
check(seconds?.let { it in secondsRange } ?: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
||||||
@ -36,11 +36,11 @@ internal data class CronDateTime(
|
|||||||
minutes: Int? = null,
|
minutes: Int? = null,
|
||||||
seconds: Int? = null
|
seconds: Int? = null
|
||||||
) = CronDateTime(
|
) = CronDateTime(
|
||||||
month ?.clamp(com.insanusmokrassar.krontab.internal.monthRange) ?.toByte(),
|
month ?.clamp(monthRange) ?.toByte(),
|
||||||
dayOfMonth ?.clamp(com.insanusmokrassar.krontab.internal.dayOfMonthRange) ?.toByte(),
|
dayOfMonth ?.clamp(dayOfMonthRange) ?.toByte(),
|
||||||
hours ?.clamp(com.insanusmokrassar.krontab.internal.hoursRange) ?.toByte(),
|
hours ?.clamp(hoursRange) ?.toByte(),
|
||||||
minutes ?.clamp(com.insanusmokrassar.krontab.internal.minutesRange) ?.toByte(),
|
minutes ?.clamp(minutesRange) ?.toByte(),
|
||||||
seconds ?.clamp(com.insanusmokrassar.krontab.internal.secondsRange) ?.toByte()
|
seconds ?.clamp(secondsRange) ?.toByte()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user