krontab/src/commonMain/kotlin/com/insanusmokrassar/krontab/SchedulerShortcuts.kt

50 lines
1.4 KiB
Kotlin
Raw Normal View History

package com.insanusmokrassar.krontab
2019-10-08 17:04:58 +00:00
import com.insanusmokrassar.krontab.builder.buildSchedule
2019-10-10 08:25:55 +00:00
import com.insanusmokrassar.krontab.internal.CronDateTime
2020-06-03 15:07:10 +00:00
import com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
2019-10-08 17:04:58 +00:00
internal val anyCronDateTime by lazy {
CronDateTime()
}
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now]
*/
2019-10-10 10:43:52 +00:00
val AnyTimeScheduler: KronScheduler by lazy {
2019-10-08 17:04:58 +00:00
CronDateTimeScheduler(listOf(anyCronDateTime))
}
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now] + one second
*/
2019-10-10 10:43:52 +00:00
val EverySecondScheduler: KronScheduler
2019-10-08 17:04:58 +00:00
get() = AnyTimeScheduler
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now] + one minute
*/
2019-10-10 10:43:52 +00:00
val EveryMinuteScheduler: KronScheduler by lazy {
2019-10-08 17:04:58 +00:00
buildSchedule { minutes { 0 every 1 } }
}
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now] + one hour
*/
2019-10-10 10:43:52 +00:00
val EveryHourScheduler: KronScheduler by lazy {
2019-10-08 17:04:58 +00:00
buildSchedule { hours { 0 every 1 } }
}
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now] + one day
*/
2019-10-10 10:43:52 +00:00
val EveryDayOfMonthScheduler: KronScheduler by lazy {
2019-10-08 17:04:58 +00:00
buildSchedule { dayOfMonth { 0 every 1 } }
}
2020-06-03 14:41:54 +00:00
/**
* [KronScheduler.next] will always return [com.soywiz.klock.DateTime.now] + one month
*/
2019-10-10 10:43:52 +00:00
val EveryMonthScheduler: KronScheduler by lazy {
2019-10-08 17:04:58 +00:00
buildSchedule { months { 0 every 1 } }
}