mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
several renamings
This commit is contained in:
parent
8310f91745
commit
3dc06571c8
@ -12,37 +12,37 @@ private val incomeSecondRange = 0 .. 59
|
|||||||
fun CronDateTime(
|
fun CronDateTime(
|
||||||
month: Int? = null,
|
month: Int? = null,
|
||||||
dayOfMonth: Int? = null,
|
dayOfMonth: Int? = null,
|
||||||
hour: Int? = null,
|
hours: Int? = null,
|
||||||
minute: Int? = null,
|
minutes: Int? = null,
|
||||||
second: Int? = null
|
seconds: Int? = null
|
||||||
) = CronDateTime(
|
) = CronDateTime(
|
||||||
month ?.clamp(incomeMonthRange) ?.toByte(),
|
month ?.clamp(incomeMonthRange) ?.toByte(),
|
||||||
dayOfMonth ?.clamp(incomeDayOfMonthRange) ?.toByte(),
|
dayOfMonth ?.clamp(incomeDayOfMonthRange) ?.toByte(),
|
||||||
hour ?.clamp(incomeHourRange) ?.toByte(),
|
hours ?.clamp(incomeHourRange) ?.toByte(),
|
||||||
minute ?.clamp(incomeMinuteRange) ?.toByte(),
|
minutes ?.clamp(incomeMinuteRange) ?.toByte(),
|
||||||
second ?.clamp(incomeSecondRange) ?.toByte()
|
seconds ?.clamp(incomeSecondRange) ?.toByte()
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [month] 0-11
|
* [month] 0-11
|
||||||
* [dayOfMonth] 0-31
|
* [dayOfMonth] 0-31
|
||||||
* [hour] 0-23
|
* [hours] 0-23
|
||||||
* [minute] 0-59
|
* [minutes] 0-59
|
||||||
* [second] 0-59
|
* [seconds] 0-59
|
||||||
*/
|
*/
|
||||||
data class CronDateTime(
|
data class CronDateTime(
|
||||||
val month: Byte? = null,
|
val month: Byte? = null,
|
||||||
val dayOfMonth: Byte? = null,
|
val dayOfMonth: Byte? = null,
|
||||||
val hour: Byte? = null,
|
val hours: Byte? = null,
|
||||||
val minute: Byte? = null,
|
val minutes: Byte? = null,
|
||||||
val second: Byte? = null
|
val seconds: Byte? = null
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
check(month ?.let { it in incomeMonthRange } ?: true)
|
check(month ?.let { it in incomeMonthRange } ?: true)
|
||||||
check(dayOfMonth ?.let { it in incomeDayOfMonthRange } ?: true)
|
check(dayOfMonth ?.let { it in incomeDayOfMonthRange } ?: true)
|
||||||
check(hour ?.let { it in incomeHourRange } ?: true)
|
check(hours?.let { it in incomeHourRange } ?: true)
|
||||||
check(minute ?.let { it in incomeMinuteRange } ?: true)
|
check(minutes?.let { it in incomeMinuteRange } ?: true)
|
||||||
check(second ?.let { it in incomeSecondRange } ?: true)
|
check(seconds?.let { it in incomeSecondRange } ?: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
||||||
@ -51,17 +51,17 @@ data class CronDateTime(
|
|||||||
fun CronDateTime.toNearDateTime(relativelyTo: DateTime = DateTime.now()): DateTime {
|
fun CronDateTime.toNearDateTime(relativelyTo: DateTime = DateTime.now()): DateTime {
|
||||||
var current = relativelyTo
|
var current = relativelyTo
|
||||||
|
|
||||||
second ?.let {
|
seconds?.let {
|
||||||
val left = it - current.seconds
|
val left = it - current.seconds
|
||||||
current += DateTimeSpan(minutes = if (left < 0) 1 else 0, seconds = left)
|
current += DateTimeSpan(minutes = if (left < 0) 1 else 0, seconds = left)
|
||||||
}
|
}
|
||||||
|
|
||||||
minute ?.let {
|
minutes?.let {
|
||||||
val left = it - current.minutes
|
val left = it - current.minutes
|
||||||
current += DateTimeSpan(hours = if (left < 0) 1 else 0, minutes = left)
|
current += DateTimeSpan(hours = if (left < 0) 1 else 0, minutes = left)
|
||||||
}
|
}
|
||||||
|
|
||||||
hour ?.let {
|
hours?.let {
|
||||||
val left = it - current.hours
|
val left = it - current.hours
|
||||||
current += DateTimeSpan(days = if (left < 0) 1 else 0, hours = left)
|
current += DateTimeSpan(days = if (left < 0) 1 else 0, hours = left)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user