public
Created

  • Download Gist
so-4226197.scala
Scala
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
import org.scala_tools.time.Imports._
import org.scala_tools.time.Implicits._
 
case class Event(id: String, startDate: LocalDateTime, action: String)
 
case class Events(events: List[Event], timeout: Int) {
 
val timeoutDt: LocalDateTime = new LocalDateTime().minusMinutes(timeout)
 
lazy val oldEvents = events.filter { (e: Event) =>
e.startDate < timeoutDt
}
 
lazy val eventsToSend = events.filterNot { (e: Event) =>
e.startDate < timeoutDt
}
}
 
object Main {
 
 
def main(args:Array[String]) {
 
val d1 = new LocalDateTime("2010-11-17T10:10:10")
val d2 = new LocalDateTime("2012-11-17T10:10:10")
val e1 = new Event("a", d1, "a")
val e2 = new Event("b", d2, "b")
val es = Events(List(e1, e2), 10000)
val old = es.oldEvents
 
}
 
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.