Back to results · bugfix-hard/opus-5-5-run-1/REPORT.md
# Investigation of customer complaints Seven of the ten complaints were real bugs, and each is fixed with a one-line change. The other three (4, 9 and 10) describe correct, documented behaviour, so the code was not changed for them. | # | Complaint | Real bug? | File changed | |---|-----------|-----------|--------------| | 1 | Month-end billing dates a day out in some years | Yes | `relativedelta.py` | | 2 | Bookings just after midnight show up mid-day | Yes | `parser/_parser.py` | | 3 | "Last Friday" meeting put a week early | Yes | `rrule.py` | | 4 | 31 Jan + 1 month gives end of February | **No** | – | | 5 | Reminders with an end date stop one too soon | Yes | `rrule.py` | | 6 | Orthodox Easter one day off | Yes | `easter.py` | | 7 | ISO week numbers a week early in some years | Yes | `parser/isoparser.py` | | 8 | Shift starting exactly at the clock change shown in the wrong zone | Yes | `tz/_tzfile.py` | | 9 | UK user's 01/02/2026 read as 2 January | **No** | – | | 10 | Easter 2026 is 5 April, Greek office says 12 April | **No** (same cause as 6 if they used the Orthodox method) | – | ## Details ### 1. Month-end billing dates sometimes a day out — real bug **Cause:** `relativedelta.__add__` limits the day to the length of the target month. It looked up that length using the year of the *starting* date (`other.year`) instead of the year of the *result*. So whenever adding months crossed into a different year, February got the wrong number of days. For example, 31 Dec 2023 + 2 months gave 28 Feb 2024 instead of 29 Feb 2024. In the other direction it could crash: 29 Feb 2024 + 1 year raised `ValueError: day is out of range`. It only shows up when the start and result years differ and one of them is a leap year, which is why it "does not happen every year". **Fix:** `calendar.monthrange(other.year, month)` → `calendar.monthrange(year, month)`. ### 2. Bookings just after midnight show up mid-day — real bug **Cause:** `parser._adjust_ampm` added 12 to PM hours but had no rule for 12 AM. So "12:15 AM" was read as 12:15 (midday) instead of 00:15. **Fix:** added the missing case: 12 with AM becomes hour 0. 12 PM still gives 12, and the other hours are unchanged. ### 3. "Last Friday" monthly meeting a week early — real bug **Cause:** In `rrule` (`_iterinfo.rebuild`), the code for negative weekday positions (`BYDAY=-1FR`, `FR(-1)`) counted back from the end of the month with `last + n*7`. That is one week too far: -1 gave the second-to-last Friday, -2 the third-to-last, and so on. **Fix:** `i = last + n*7` → `i = last + (n+1)*7`. ### 4. One month after 31 January should be early March — not a bug `relativedelta(months=+1)` moves to the same day of the next month. If that day does not exist, it uses the last day of that month. This is the documented behaviour, and 31 Jan + 1 month = 28/29 Feb is intended. Customers who want "31 days later" should use `relativedelta(days=+31)` or `timedelta(days=31)`. No change. ### 5. Repeating reminders with an end date stop one occurrence too soon — real bug **Cause:** The documentation says the last occurrence is the last one *less than or equal to* `until`. The main loop in `rrule._iter` stopped on `res >= until`, so an occurrence exactly at the end date was dropped. The `bysetpos` branch already used `>`. **Fix:** `res >= until` → `res > until`. ### 6. Orthodox Easter one day off — real bug **Cause:** For `EASTER_ORTHODOX`, `easter()` converts the Julian date to the Gregorian calendar by adding the gap between the two calendars: `10 + (century − 16) − (century − 16)//4`. The code divided by 5 instead of 4. From 2000 onward, that made the gap one day too large (14 instead of 13 days), so Orthodox Easter came out one day late (and on a Monday). **Fix:** `//5` → `//4`. Results now match the published dates, for example 2024-05-05, 2025-04-20 and 2026-04-12. ### 7. ISO week numbers a week early in some years — real bug **Cause:** `isoparser._calculate_weekdate` (used for strings like `2026-W10-1`) found week 1 by taking the Monday on or before **1 January**. ISO week 1 is the week that contains **4 January**. In years where 1 January falls on a Friday, Saturday or Sunday, this gave the previous week, so every week came out 7 days early. In other years it was correct. **Fix:** use 4 January as the reference date. ### 8. Shift starting exactly at the clock change shown in the wrong time zone — real bug **Cause:** `tzfile._find_trans` found the current time-zone rule with `bisect.bisect_left(...) - 1`. When the local time was *exactly* the moment of a change, this picked the rule from *before* the change (e.g. GMT instead of BST at 02:00 on the spring-forward day). One second later it was correct. If the time exactly matched the very first transition in the file, it raised an `AssertionError`. **Fix:** `bisect_left` → `bisect_right`, so a time on the boundary belongs to the new period. ### 9. UK user typed 01/02/2026 and got 2 January — not a bug `dateutil.parser.parse` reads ambiguous numeric dates month-first by default (US convention). This is documented, and the default is `dayfirst=False`. UK users should call `parse(s, dayfirst=True)`, or use a `parserinfo(dayfirst=True)`, which gives 1 February 2026. Unambiguous inputs such as `13/01/2026` already work either way. No change. ### 10. Easter 2026 is 5 April but the Greek office says 12 April — not a bug `easter(2026)` uses the Western method by default, and Western Easter 2026 is 5 April. The Greek office follows the Orthodox calendar, which needs `easter(2026, EASTER_ORTHODOX)`. Before the fix for #6, that call gave 13 April. It now gives 12 April. No change for this complaint itself. ## Verification - I wrote my own check script and ran it with `PYTHONPATH=src` against both the original code (a clean copy of `HEAD`) and the fixed code: - **Month-end dates:** compared against end-of-month dates worked out independently. - **Last Friday and other weekday positions:** checked over 2020–2030. - **`until`:** checked that an occurrence exactly on the end date is included. - **Orthodox Easter:** checked against known dates, and for 1583–4099 against "Julian Easter + calendar gap". - **ISO weeks:** checked against Python's `date.fromisocalendar` for 1990–2039. - **Time zones:** compared `utcoffset`/`tzname`/`dst`/`fromutc` with the standard library's `zoneinfo` for several zones, daily over 2020–2045. I also checked about 19,500 times within an hour either side of every transition. - Each bug-specific check fails on the original code and passes on the fixed code. - **Regression comparison:** I ran about 4,900 lines of mixed operations on both versions: parser formats with all option combinations, many `rrule` types, `relativedelta` arithmetic and differences, all three Easter methods, and time-zone lookups. The only output differences are the intended ones: 12:xx a.m. times, Orthodox Easter dates from 2000 onward, and `until`-bounded rules now including the end date. - **Note for anyone re-running the checks:** this machine stores Python bytecode in a shared cache (`sys.pycache_prefix`). It can serve stale code after switching file versions (e.g. with `git stash`), so set a fresh `PYTHONPYCACHEPREFIX` when comparing versions.