Skip to content

Migrating from businesstimedelta

Karthik P edited this page Oct 25, 2026 · 3 revisions

Most code migrates with one line:

import workclock.compat as businesstimedelta

workclock.compat mirrors businesstimedelta 1.0.1: WorkDayRule, LunchTimeRule, HolidayRule, Rules and BusinessTimeDelta, with the same arguments, defaults and operators. businesstimedelta's own test suite runs against it in CI.

What changes for existing code:

  • Fixed: overnight shifts, TypeError past the last holiday (#8, #10), infinite loops with holidays in another zone (#9), time off that starts inside a working period, and searches that never end.
  • Different on purpose: results come back in the tzinfo you passed in; negative deltas move the other way; times repeated at the end of DST resolve to their first occurrence; holidays on DST days last 23 or 25 hours; python-holidays objects are read once for 1970–2100; custom Rule subclasses and nested Rules raise TypeError.

MIGRATING.md has the full list with examples.

For new code, the typed workclock.Schedule API is smaller and stricter: it rejects naive datetimes, returns a signed between (#12) and has batch methods for lists and NumPy arrays. See Getting Started.

Clone this wiki locally