fix tests

This commit is contained in:
InsanusMokrassar 2021-06-03 12:16:39 +06:00
parent b4790b892a
commit c3ed1d024c
2 changed files with 10 additions and 5 deletions

View File

@ -3,9 +3,7 @@
## 0.6.1
* Versions
* `Klock`: `2.1.0` -> `2.1.2
`
* `Klock`: `2.1.0` -> `2.1.2`
## 0.6.0

View File

@ -15,9 +15,16 @@ import kotlinx.coroutines.flow.*
*/
@FlowPreview
fun KronScheduler.asTzFlow(): Flow<DateTimeTz> = channelFlow {
var previousTime = DateTime.nowLocal()
while (isActive) {
val now = DateTime.now().local
val now = DateTime.nowLocal()
val nextTime = next(now) ?: break
if (previousTime == nextTime) {
delay(1L) // skip 1ms
continue
} else {
previousTime = nextTime
}
val sleepDelay = (nextTime - DateTime.now().local).millisecondsLong
delay(sleepDelay)
send(nextTime)