Created
October 6, 2019 19:07
-
-
Save danslapman/c389ed8cec609475b1716e81af937417 to your computer and use it in GitHub Desktop.
DateTime range
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
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