Conversation
Signed-off-by: Gerhard Riegler <gerhard.riegler@gmail.com>
Signed-off-by: Gerhard Riegler <gerhard.riegler@gmail.com>
long matchStart = start != null ? start.getTimeInMillis() | ||
: DateTimeUtils.truncateToMidnight(cal).getTimeInMillis(); | ||
long matchEnd = end != null ? end.getTimeInMillis() : DateTimeUtils.truncateToMidnight(cal).getTimeInMillis(); | ||
return cal.getTimeInMillis() >= matchStart && cal.getTimeInMillis() < matchEnd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no start/end are given, then both conditions are comparing against DateTimeUtils.truncateToMidnight(cal)
. How can this ever be true? Doesn't matchEnd
needs 24h added in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Range start/end are always for the current day. If no start/end are given (e.g night in northern hemisphere), there is nothing to match and should return false. So it's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see. Thanks for the clarification!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, wait, I still don't fully get it - can it happen that only one is given? I.e. if there is only a start, then it would also return false (because the second part is using the previous midnight), even if cal is after matchStart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right! end must be truncated to endOfDay and not to midnight. Thanks!!!
Signed-off-by: Gerhard Riegler <gerhard.riegler@gmail.com>
Thank you! |
fixes #4138