2012-09-13 11:16:01 +02:00
|
|
|
/**
|
2014-02-02 19:05:45 -06:00
|
|
|
* Copyright (C) 2013-2014 Typesafe Inc. <http://www.typesafe.com>
|
2012-09-13 11:16:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package docs.duration
|
|
|
|
|
|
2012-10-15 15:24:48 +02:00
|
|
|
import language.postfixOps
|
|
|
|
|
|
2012-09-13 11:16:01 +02:00
|
|
|
object Scala {
|
|
|
|
|
//#dsl
|
2012-09-21 14:50:06 +02:00
|
|
|
import scala.concurrent.duration._
|
2012-09-13 11:16:01 +02:00
|
|
|
|
|
|
|
|
val fivesec = 5.seconds
|
|
|
|
|
val threemillis = 3.millis
|
|
|
|
|
val diff = fivesec - threemillis
|
|
|
|
|
assert(diff < fivesec)
|
2012-09-26 10:56:25 +02:00
|
|
|
val fourmillis = threemillis * 4 / 3 // you cannot write it the other way around
|
2012-09-13 11:16:01 +02:00
|
|
|
val n = threemillis / (1 millisecond)
|
|
|
|
|
//#dsl
|
|
|
|
|
|
|
|
|
|
//#deadline
|
|
|
|
|
val deadline = 10.seconds.fromNow
|
|
|
|
|
// do something
|
|
|
|
|
val rest = deadline.timeLeft
|
|
|
|
|
//#deadline
|
|
|
|
|
}
|