mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 08:13:54 +00:00
add note about offsets
This commit is contained in:
parent
20f12f3f2d
commit
da88d18d4d
18
README.md
18
README.md
@ -14,7 +14,8 @@ runtime of applications.
|
||||
| [ How to use: Config from string ](#config-from-string) |
|
||||
| [ How to use: Config via builder (DSL preview) ](#config-via-builder) |
|
||||
| [ How to use: KronScheduler as a Flow ](#KronScheduler-as-a-Flow) |
|
||||
| [ Note about week days ](#Note-about-week-days) |
|
||||
| [ How to use: Offsets ](#Offsets) |
|
||||
| [ How to use: Note about week days ](#Note-about-week-days) |
|
||||
|
||||
## How to use
|
||||
|
||||
@ -157,6 +158,21 @@ flow.takeWhile {
|
||||
}
|
||||
```
|
||||
|
||||
### Offsets
|
||||
|
||||
Offsets in this library works via passing parameter ending with `o` in any place after `month` config. Currently
|
||||
there is only one format supported for offsets: minutes of offsets. To use time zones you will need to call `next`
|
||||
method with `DateTimeTz` argument or `nextTimeZoned` method with any `KronScheduler` instance, but in case if this
|
||||
scheduler is not instance of `KronSchedulerTz` it will works like you passed just `DateTime`.
|
||||
|
||||
Besides, in case you wish to use time zones explicitly, you will need to get `KronSchedulerTz`. It is possible by:
|
||||
|
||||
* Using `createSimpleScheduler`/`buildSchedule`/`KrontabTemplate#toSchedule`/`KrontabTemplate#toKronScheduler` methods
|
||||
with passing `defaultOffset` parameter
|
||||
* Using `SchedulerBuilder#build`/`createSimpleScheduler`/`buildSchedule`/`KrontabTemplate#toSchedule`/`KrontabTemplate#toKronScheduler`
|
||||
methods with casting to `KronSchedulerTz` in case you are pretty sure that it is timezoned `KronScheduler`
|
||||
* Creating your own implementation of `KronSchedulerTz`
|
||||
|
||||
### Note about week days
|
||||
|
||||
Unlike original CRON, here week days:
|
||||
|
@ -29,4 +29,6 @@ suspend fun KronScheduler.next(relatively: DateTimeTz) = if (this is KronSchedul
|
||||
this.next(relatively)
|
||||
} else {
|
||||
this.next(relatively.local) ?.toOffsetUnadjusted(relatively.offset)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun KronScheduler.nextTimeZoned() = next(DateTime.now().local)
|
Loading…
Reference in New Issue
Block a user