Skip to content

Instantly share code, notes, and snippets.

@fedesilva
Created November 19, 2010 15:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fedesilva/706675 to your computer and use it in GitHub Desktop.
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment