dererXII.scalashogi_2.13.5.0.2.source-code.Timestamp.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalashogi_2.13 Show documentation
Show all versions of scalashogi_2.13 Show documentation
Shogi API written in scala. Immutable and free of side effects.
package shogi
final case class Timestamp(value: Long) extends AnyVal with Ordered[Timestamp] {
def -(o: Timestamp) = Centis.ofMillis(value - o.value)
def +(o: Centis) = Timestamp(value + o.millis)
def compare(other: Timestamp) = java.lang.Long.compare(value, other.value)
}
trait Timestamper {
def now: Timestamp
def toNow(ts: Timestamp) = now - ts
}
private[shogi] object RealTimestamper extends Timestamper {
def now = new Timestamp(System.currentTimeMillis)
}