mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
add "every" and "upTo" infix functions in time builder
This commit is contained in:
parent
b9bb7f3373
commit
b93b9fd7c7
@ -12,14 +12,6 @@ fun buildSchedule(settingsBlock: SchedulerBuilder.() -> Unit): CronDateTimeSched
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
//infix fun Int.withStep(step: Int): PropertyHolder {
|
||||
// return DivPropertyHolder(this, step)
|
||||
//}
|
||||
//
|
||||
//operator fun Int.minus(including: Int): PropertyHolder {
|
||||
// return RangePropertyHolder(this, including)
|
||||
//}
|
||||
|
||||
class SchedulerBuilder(
|
||||
private var seconds: Array<Byte>? = null,
|
||||
private var minutes: Array<Byte>? = null,
|
||||
|
@ -21,7 +21,7 @@ sealed class TimeBuilder (
|
||||
result = (result ?: emptySet()) + value.clamp(restrictionsRange)
|
||||
}
|
||||
|
||||
inline infix fun from(value: Int) = value
|
||||
inline fun from(value: Int) = value
|
||||
|
||||
infix fun Int.every(delay: Int): Array<Int> {
|
||||
val progression = clamp(restrictionsRange) .. restrictionsRange.last step delay
|
||||
@ -31,6 +31,7 @@ sealed class TimeBuilder (
|
||||
|
||||
return result
|
||||
}
|
||||
infix fun every(delay: Int): Array<Int> = 0 every delay
|
||||
|
||||
infix fun Int.upTo(endIncluding: Int): Array<Int> {
|
||||
val progression = clamp(restrictionsRange) .. endIncluding.clamp(restrictionsRange)
|
||||
@ -40,6 +41,7 @@ sealed class TimeBuilder (
|
||||
|
||||
return result
|
||||
}
|
||||
infix fun upTo(endIncluding: Int): Array<Int> = 0 upTo endIncluding
|
||||
|
||||
internal fun build() = result ?.map { it.toByte() } ?.toTypedArray()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user