mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2024-06-03 00:15:13 +00:00
18 lines
793 B
Kotlin
18 lines
793 B
Kotlin
package com.github.insanusmokrassar.SauceNaoAPI.utils
|
|
|
|
import com.github.insanusmokrassar.SauceNaoAPI.additional.LONG_TIME_RECALCULATING_MILLIS
|
|
import com.github.insanusmokrassar.SauceNaoAPI.additional.SHORT_TIME_RECALCULATING_MILLIS
|
|
import com.github.insanusmokrassar.SauceNaoAPI.models.Header
|
|
import org.joda.time.DateTime
|
|
|
|
internal suspend fun calculateSleepTime(
|
|
header: Header,
|
|
mostOldestInShortPeriodGetter: suspend () -> DateTime?,
|
|
mostOldestInLongPeriodGetter: suspend () -> DateTime?
|
|
): DateTime? {
|
|
return when {
|
|
header.longRemaining < 1 -> mostOldestInLongPeriodGetter() ?.plusMillis(LONG_TIME_RECALCULATING_MILLIS)
|
|
header.shortRemaining < 1 -> mostOldestInShortPeriodGetter() ?.plusMillis(SHORT_TIME_RECALCULATING_MILLIS)
|
|
else -> null
|
|
}
|
|
} |