mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
fix tests
This commit is contained in:
parent
b4790b892a
commit
c3ed1d024c
@ -3,9 +3,7 @@
|
|||||||
## 0.6.1
|
## 0.6.1
|
||||||
|
|
||||||
* Versions
|
* Versions
|
||||||
* `Klock`: `2.1.0` -> `2.1.2
|
* `Klock`: `2.1.0` -> `2.1.2`
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
## 0.6.0
|
## 0.6.0
|
||||||
|
|
||||||
|
@ -15,9 +15,16 @@ import kotlinx.coroutines.flow.*
|
|||||||
*/
|
*/
|
||||||
@FlowPreview
|
@FlowPreview
|
||||||
fun KronScheduler.asTzFlow(): Flow<DateTimeTz> = channelFlow {
|
fun KronScheduler.asTzFlow(): Flow<DateTimeTz> = channelFlow {
|
||||||
|
var previousTime = DateTime.nowLocal()
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
val now = DateTime.now().local
|
val now = DateTime.nowLocal()
|
||||||
val nextTime = next(now) ?: break
|
val nextTime = next(now) ?: break
|
||||||
|
if (previousTime == nextTime) {
|
||||||
|
delay(1L) // skip 1ms
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
previousTime = nextTime
|
||||||
|
}
|
||||||
val sleepDelay = (nextTime - DateTime.now().local).millisecondsLong
|
val sleepDelay = (nextTime - DateTime.now().local).millisecondsLong
|
||||||
delay(sleepDelay)
|
delay(sleepDelay)
|
||||||
send(nextTime)
|
send(nextTime)
|
||||||
|
Loading…
Reference in New Issue
Block a user