Created
November 19, 2010 15:52
-
-
Save fedesilva/706675 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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