Colton Idle
02/13/2025, 10:08 PMhho
02/13/2025, 10:13 PMphldavies
02/13/2025, 10:28 PMfun durationToNextMinute(): Duration {
val now = Clock.System.now()
val local = now.toLocalDateTime(TimeZone.currentSystemDefault())
val nextMinute = local.date.atTime(local.hour, local.minute + 1)
return nextMinute.toInstant(TimeZone.currentSystemDefault()) - now
}
suspend fun delayUntilNextMinute() = delay(durationToNextMinute())
Colton Idle
02/13/2025, 10:33 PMJoe
02/13/2025, 10:38 PMColton Idle
02/13/2025, 10:39 PMCasey Brooks
02/13/2025, 10:56 PMColton Idle
02/13/2025, 11:03 PMphldavies
02/13/2025, 11:06 PMphldavies
02/13/2025, 11:07 PMColton Idle
02/13/2025, 11:09 PMfun durationToNextMinute(): Duration {
val now = Clock.System.now()
val local = now.toLocalDateTime(TimeZone.currentSystemDefault())
val nextMinute = local.date.atTime(local.hour, local.minute)
return (nextMinute.toInstant(TimeZone.currentSystemDefault()) - now) + 1.minutes
}
?phldavies
02/13/2025, 11:11 PMColton Idle
02/13/2025, 11:13 PMCasey Brooks
02/13/2025, 11:13 PMInstant
you need to trigger, then delay by the difference in time between Clock.System.now()
and that Instant
https://github.com/copper-leaf/ballast/blob/main/ballast-schedules/src/commonMain/kotlin/com/copperleaf/ballast/scheduler/schedule/EveryMinuteSchedule.kt#L15-L42
https://github.com/copper-leaf/ballast/blob/main/ballast-schedules/src/commonMain/kotlin/com/copperleaf/ballast/scheduler/executor/CoroutineClockScheduleExecutor.kt#L13-L41