mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2025-12-06 04:55:52 +00:00
add support of ranges in strings
This commit is contained in:
@@ -81,6 +81,16 @@ sealed class TimeBuilder (
|
||||
*/
|
||||
@Suppress("unused")
|
||||
infix fun upTo(endIncluding: Int): Array<Int> = this from 0 upTo endIncluding
|
||||
/**
|
||||
* Will fill up this timeline from [this] up to [endIncluding]
|
||||
*/
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
infix operator fun Int.rangeTo(endIncluding: Int) = upTo(endIncluding)
|
||||
/**
|
||||
* Shortcut for "[from] 0 [rangeTo] [endIncluding]"
|
||||
*/
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
infix operator fun rangeTo(endIncluding: Int) = (this from 0) rangeTo endIncluding
|
||||
|
||||
internal fun build() = result ?.map { it.toByte() } ?.toTypedArray()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ private fun createSimpleScheduler(from: String, dataRange: IntRange): Array<Byte
|
||||
|
||||
val results = things.flatMap {
|
||||
when {
|
||||
it.contains("-") -> {
|
||||
val splitted = it.split("-")
|
||||
(splitted.first().toInt().clamp(dataRange) .. splitted[1].toInt().clamp(dataRange)).toList()
|
||||
}
|
||||
it.contains("/") -> {
|
||||
val (start, step) = it.split("/")
|
||||
val startNum = (if (start.isEmpty() || start == "*") {
|
||||
|
||||
Reference in New Issue
Block a user