https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42334 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 208482 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208482&action=edit Bug 42334: Use DateCalculator and remove days_mode from Koha::Library::Calendar This patch moves all callers of the date arithmetic methods to Koha::Library::Calendar::DateCalculator, obtained through the new date_calculator accessor, and removes the moved methods and the days_mode parameter from Koha::Library::Calendar. Changes: - Remove addDuration, addDays, addHours, get_push_amt, next_open_days and prev_open_days from Koha::Library::Calendar - Remove the unused set_daysmode and clear_weekly_closed_days methods and the {test} flag they relied on - days_forward no longer requires days_mode, which it never used - Koha::Hold->set_waiting no longer looks up the effective daysmode, it was only computed to satisfy the days_forward check - Adapt CalcDateDue, checkHighHolds, _calculate_new_debar_dt, Koha::Checkouts->calculate_dropbox_date, holds_reminder.pl and TalkingTech_itiva_outbound.pl - Adapt tests The counting methods (days_between, hours_between, has_business_days_between, days_forward) stay in Koha::Library::Calendar: they don't depend on any useDaysMode policy. Only behavior change: an invalid days_mode (useDaysMode syspref or daysmode circulation rule) now throws Koha::Exceptions::WrongParameter instead of silently behaving like 'Days'. Neither smart-rules.pl nor the circulation rules API validate the daysmode value, so a misconfigured rule now makes due date calculations fail loudly. CalcDateDue.t used such an invalid value (noDays) and is adapted to use Datedue, which matches its intent. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Calendar.t \ t/db_dependent/Koha/Library/Calendar.t \ t/db_dependent/Koha/Library/Calendar/DateCalculator.t \ t/db_dependent/Circulation/CalcDateDue.t \ t/db_dependent/Circulation.t \ t/db_dependent/Hold.t \ t/db_dependent/Holds.t \ t/db_dependent/Koha/Checkouts.t \ t/db_dependent/Koha/Hold.t => SUCCESS: Tests pass! 3. Verify no references to the removed methods remain: k$ git grep -nE '\->(addDuration|addDays|addHours|get_push_amt|set_daysmode|clear_weekly_closed_days)\b' -- ':!misc/release_notes' => SUCCESS: No results 4. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.