src/Pure/General/time.scala
author wenzelm
Thu, 01 Dec 2011 14:29:14 +0100
changeset 45709 87017fcbad83
parent 45674 eb65c9d17e2f
child 46712 8650d9a95736
permissions -rw-r--r--
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;

/*  Title:      Pure/General/time.scala
    Module:     PIDE
    Author:     Makarius

Time based on milliseconds.
*/

package isabelle


object Time
{
  def seconds(s: Double): Time = new Time((s * 1000.0) round)
  def ms(m: Long): Time = new Time(m)
}

class Time private(val ms: Long)
{
  def seconds: Double = ms / 1000.0

  def min(t: Time): Time = if (ms < t.ms) this else t
  def max(t: Time): Time = if (ms > t.ms) this else t

  override def toString =
    String.format(java.util.Locale.ROOT, "%.3f", seconds.asInstanceOf[AnyRef])
  def message: String = toString + "s"
}