Introduce ClockMark.hasPassedNow, hasNotPassedNow functions
Makes it more clear to use them than comparing elapsed with Duration.ZERO.
This commit is contained in:
@@ -52,6 +52,23 @@ public abstract class ClockMark {
|
||||
* The returned clock mark is more _early_ when the [duration] is positive, and more _late_ when the [duration] is negative.
|
||||
*/
|
||||
public open operator fun minus(duration: Duration): ClockMark = plus(-duration)
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this clock mark has passed according to the clock from which this mark was taken.
|
||||
*
|
||||
* Note that the value returned by this function can change on subsequent invocations.
|
||||
* If the clock is monotonic, it can change only from `false` to `true`, namely, when the clock mark becomes behind the current point of the clock.
|
||||
*/
|
||||
public fun hasPassedNow(): Boolean = !elapsedNow().isNegative()
|
||||
|
||||
/**
|
||||
* Returns false if this clock mark has not passed according to the clock from which this mark was taken.
|
||||
*
|
||||
* Note that the value returned by this function can change on subsequent invocations.
|
||||
* If the clock is monotonic, it can change only from `true` to `false`, namely, when the clock mark becomes behind the current point of the clock.
|
||||
*/
|
||||
public fun hasNotPassedNow(): Boolean = elapsedNow().isNegative()
|
||||
}
|
||||
|
||||
@ExperimentalTime
|
||||
|
||||
Reference in New Issue
Block a user