
walkmc.time.StartedTime.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of walk-server Show documentation
Show all versions of walk-server Show documentation
A spigot fork to kotlin structure and news.
package walkmc.time
import com.soywiz.klock.*
import walkmc.extensions.*
import kotlin.time.*
/**
* A started time is a time thats holds a start millis, representing the
* current time millis of this time starteds.
*/
interface StartedTime : Comparable {
override fun compareTo(other: StartedTime): Int = lifetime.compareTo(other.lifetime)
/**
* The started cached millis.
*/
var startMillis: Long
}
/**
* Returns the lifetime of this countdown.
*/
inline val StartedTime.lifetime: Long
get() = currentMillis - startMillis
/**
* Redefines this started time, this is, reseting their lifetime.
*/
fun StartedTime.redefine() {
startMillis = currentMillis
}
/**
* Returns if the lifetime of this started time is more than the specified [timespan]
*/
operator fun StartedTime.compareTo(timespan: TimeSpan): Int = lifetime.compareTo(timespan.millisecondsLong)
/**
* Returns if the lifetime of this started time is more than the specified [duration]
*/
operator fun StartedTime.compareTo(duration: Duration): Int = lifetime.compareTo(duration.inWholeMilliseconds)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy