Prevent clamping dates that start after the end of the month

Signed-off-by: Ben Ridley <benridley29@gmail.com>
This commit is contained in:
Ben Ridley 2020-11-17 11:26:29 +11:00
parent adf94c3168
commit 2c86b696c9
1 changed files with 4 additions and 0 deletions

View File

@ -363,6 +363,10 @@ func (tp TimeInterval) ContainsTime(t time.Time) bool {
} else {
end = validDates.End
}
// Skip clamping if the beginning date is after the end of the month
if begin > daysInMonth {
continue
}
// Clamp to the boundaries of the month to prevent crossing into other months
begin = clamp(begin, -1*daysInMonth, daysInMonth)
end = clamp(end, -1*daysInMonth, daysInMonth)