Created
November 9, 2011 13:54
-
-
Save pr1001/1351495 to your computer and use it in GitHub Desktop.
I need to tell the Dutch government how often I'm out of the country when I renew my permit. Luckily ScalaTime makes that easy to calculate.
This file contains hidden or 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.joda.time._ | |
import org.scala_tools.time.Imports._ | |
// do +1 day to be inclusive on start and end days | |
val intervals = List ( | |
// One Day | |
new DateMidnight(2011, 1, 19) to (new DateMidnight(2011, 1, 19) + 1.day), | |
// Several Days | |
new DateMidnight(2011, 2, 5) to (new DateMidnight(2011, 2, 13) + 1.day) | |
) | |
val totalDays = intervals.map(Days.daysIn(_).getDays).reduceLeft(_ + _) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment