Create a gist now

Instantly share code, notes, and snippets.

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