Compare commits

...

4 Commits

Author SHA1 Message Date
5ef6134d9f
Merge pull request #129 from InsanusMokrassar/2.6.0
2.6.0
2024-11-03 21:52:59 +06:00
b9237e13c9 fix changelog :) 2024-11-03 17:41:13 +06:00
17971ed8fb now doOnceTz works as it must 2024-11-03 17:40:42 +06:00
505108d2dd start 2.6.0 2024-11-03 17:40:12 +06:00
3 changed files with 9 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
## 2.6.0
* Fix of `doOnceTz` behaviour: now it will use local time as utc time to get next waking up time
## 2.5.1 ## 2.5.1
* Add cleaning up of incoming template, which must remove all malformed parts from string template (fix of [#126](https://github.com/InsanusMokrassar/krontab/issues/126)) * Add cleaning up of incoming template, which must remove all malformed parts from string template (fix of [#126](https://github.com/InsanusMokrassar/krontab/issues/126))

View File

@ -36,5 +36,5 @@ androidx_work_version=2.10.0
## Common ## Common
version=2.5.1 version=2.6.0
android_code_version=43 android_code_version=44

View File

@ -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)