several renamings

This commit is contained in:
InsanusMokrassar 2019-10-05 00:09:39 +06:00
parent 8310f91745
commit 3dc06571c8

View File

@ -12,37 +12,37 @@ private val incomeSecondRange = 0 .. 59
fun CronDateTime(
month: Int? = null,
dayOfMonth: Int? = null,
hour: Int? = null,
minute: Int? = null,
second: Int? = null
hours: Int? = null,
minutes: Int? = null,
seconds: Int? = null
) = CronDateTime(
month ?.clamp(incomeMonthRange) ?.toByte(),
dayOfMonth ?.clamp(incomeDayOfMonthRange) ?.toByte(),
hour ?.clamp(incomeHourRange) ?.toByte(),
minute ?.clamp(incomeMinuteRange) ?.toByte(),
second ?.clamp(incomeSecondRange) ?.toByte()
hours ?.clamp(incomeHourRange) ?.toByte(),
minutes ?.clamp(incomeMinuteRange) ?.toByte(),
seconds ?.clamp(incomeSecondRange) ?.toByte()
)
/**
* [month] 0-11
* [dayOfMonth] 0-31
* [hour] 0-23
* [minute] 0-59
* [second] 0-59
* [hours] 0-23
* [minutes] 0-59
* [seconds] 0-59
*/
data class CronDateTime(
val month: Byte? = null,
val dayOfMonth: Byte? = null,
val hour: Byte? = null,
val minute: Byte? = null,
val second: Byte? = null
val hours: Byte? = null,
val minutes: Byte? = null,
val seconds: Byte? = null
) {
init {
check(month ?.let { it in incomeMonthRange } ?: true)
check(dayOfMonth ?.let { it in incomeDayOfMonthRange } ?: true)
check(hour ?.let { it in incomeHourRange } ?: true)
check(minute ?.let { it in incomeMinuteRange } ?: true)
check(second ?.let { it in incomeSecondRange } ?: true)
check(hours?.let { it in incomeHourRange } ?: true)
check(minutes?.let { it in incomeMinuteRange } ?: true)
check(seconds?.let { it in incomeSecondRange } ?: true)
}
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
@ -51,17 +51,17 @@ data class CronDateTime(
fun CronDateTime.toNearDateTime(relativelyTo: DateTime = DateTime.now()): DateTime {
var current = relativelyTo
second ?.let {
seconds?.let {
val left = it - current.seconds
current += DateTimeSpan(minutes = if (left < 0) 1 else 0, seconds = left)
}
minute ?.let {
minutes?.let {
val left = it - current.minutes
current += DateTimeSpan(hours = if (left < 0) 1 else 0, minutes = left)
}
hour ?.let {
hours?.let {
val left = it - current.hours
current += DateTimeSpan(days = if (left < 0) 1 else 0, hours = left)
}