src/Pure/General/time.scala
author huffman
Tue, 27 Dec 2011 15:37:33 +0100
changeset 46001 0b562d564d5f
parent 45674 eb65c9d17e2f
child 46712 8650d9a95736
permissions -rw-r--r--
redefine some binary operations on integers work on abstract numerals instead of Int.Pls and Int.Min

/*  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"
}