Team Ai
Apppublic

cactus183/patchbench-dev

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
buggy_code.py24 linesDownload Raw Back to hard_01
1from datetime import date, timedelta2 3 4class DateRange:5    def __init__(self, start: date, end: date):6        if start > end:7            raise ValueError("start must be <= end")8        self.start = start9        self.end = end10 11    def contains(self, d: date) -> bool:12        """Check if date d is within this range (inclusive on both ends)."""13        # BUG: uses strict inequality — excludes start and end dates14        return self.start < d < self.end15 16    def overlaps(self, other: "DateRange") -> bool:17        """Check if this range overlaps with another range."""18        # BUG: uses < instead of <= so touching/adjacent ranges are not detected19        return self.start < other.end and other.start < self.end20 21    def duration_days(self) -> int:22        """Return the number of days in this range (inclusive)."""23        return (self.end - self.start).days + 124