refactor of CronDateTime

This commit is contained in:
InsanusMokrassar 2020-06-03 20:11:42 +06:00
parent 0178ac140a
commit 1f971117bd

View File

@ -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()
) )
} }
} }