Skip to content

Commit

Permalink
Reverse order of min in FiniteDatetimeRange.intersection
Browse files Browse the repository at this point in the history
In #187 the implementation of
FiniteDatetimeRange.intersection was optimised. This introduced a very
subtle change in behaviour. Previously when left.end was equal to
right.end then the right.end was favoured. In
#187 the implementation was
(unintentionally) changed to favour left.end.

This change reverses that, to again favour right.end.

This really shouldn't matter, but it can be signidicant when
the TZ of left and right are different. Eventually we'd like
to prevent this kind of mixed TZ behaviour (see
#192), but in the short
term it seems reasonable to make this tiny change to make things
consistent again with how they were before.
  • Loading branch information
Peter554 committed Jan 30, 2025
1 parent 7840053 commit 48ec2c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xocto/ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def intersection(
if left.end <= right.start:
return None
else:
return FiniteDatetimeRange(right.start, min(left.end, right.end))
return FiniteDatetimeRange(right.start, min(right.end, left.end))

base_intersection = super().intersection(other)
if base_intersection is None:
Expand Down

0 comments on commit 48ec2c2

Please sign in to comment.