mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-26 03:58:50 +00:00
now doOnceTz works as it must
This commit is contained in:
parent
505108d2dd
commit
17971ed8fb
@ -1,5 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
* Fix of `doOnceTz` behaviour: now it will use local time as utc time to get next waking up time
|
||||||
|
|
||||||
## 2.6.0
|
## 2.6.0
|
||||||
|
|
||||||
## 2.5.1
|
## 2.5.1
|
||||||
|
@ -35,6 +35,8 @@ suspend inline fun <T> KronScheduler.doOnceLocal(block: (DateTime) -> T): T = do
|
|||||||
/**
|
/**
|
||||||
* Execute [block] once at the [KronScheduler.next] time and return result of [block] calculation.
|
* Execute [block] once at the [KronScheduler.next] time and return result of [block] calculation.
|
||||||
*
|
*
|
||||||
|
* WARNING!!! This method will use local time instead of utc
|
||||||
|
*
|
||||||
* WARNING!!! If you want to launch it in parallel, you must do this explicitly.
|
* WARNING!!! If you want to launch it in parallel, you must do this explicitly.
|
||||||
*
|
*
|
||||||
* WARNING!!! In case if [KronScheduler.next] of [this] instance will return null, [block] will be called immediatelly
|
* WARNING!!! In case if [KronScheduler.next] of [this] instance will return null, [block] will be called immediatelly
|
||||||
@ -42,7 +44,7 @@ suspend inline fun <T> KronScheduler.doOnceLocal(block: (DateTime) -> T): T = do
|
|||||||
suspend inline fun <T> KronScheduler.doOnceTz(noinline block: suspend (DateTimeTz) -> T): T {
|
suspend inline fun <T> KronScheduler.doOnceTz(noinline block: suspend (DateTimeTz) -> T): T {
|
||||||
val time = when (this) {
|
val time = when (this) {
|
||||||
is KronSchedulerTz -> nextOrNowWithOffset()
|
is KronSchedulerTz -> nextOrNowWithOffset()
|
||||||
else -> nextOrNow().local
|
else -> nextTimeZoned() ?: DateTimeTz.nowLocal()
|
||||||
}
|
}
|
||||||
delay((time - DateTimeTz.nowLocal()).millisecondsLong)
|
delay((time - DateTimeTz.nowLocal()).millisecondsLong)
|
||||||
return block(time)
|
return block(time)
|
||||||
|
Loading…
Reference in New Issue
Block a user