krontab/src/commonMain/kotlin/dev/inmo/krontab/SchedulerShortcuts.kt

51 lines
1.3 KiB
Kotlin
Raw Normal View History

2020-11-21 08:58:19 +00:00
package dev.inmo.krontab
2019-10-08 17:04:58 +00:00
2020-11-21 08:58:19 +00:00
import dev.inmo.krontab.builder.buildSchedule
import dev.inmo.krontab.internal.CronDateTime
import dev.inmo.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
*/
2020-06-03 15:39:52 +00:00
val EverySecondScheduler: KronScheduler by lazy {
buildSchedule { seconds { 0 every 1 } }
}
2019-10-08 17:04:58 +00:00
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 } }
}