Skip to content

Instantly share code, notes, and snippets.

@danslapman
Created October 6, 2019 19:07
Show Gist options
  • Save danslapman/c389ed8cec609475b1716e81af937417 to your computer and use it in GitHub Desktop.
Save danslapman/c389ed8cec609475b1716e81af937417 to your computer and use it in GitHub Desktop.
DateTime range
def inRange(start: LocalTime, end: LocalTime)(dt: LocalDateTime) = {
val time = dt.toLocalTime
if (start.isBefore(end))
(time.isAfter(start) || time == start) && time.isBefore(end)
else
(time.isAfter(start) || time == start) ^ time.isBefore(end)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment