A support desk in London works 09:00 to 17:00 on weekdays, with a lunch hour, and is closed on 25 and 28 December 2026. A ticket comes in at 16:30 on Christmas Eve with an 8-hour SLA. When is it due?
The answer is 09:30 on Wednesday 30 December. Getting there means skipping lunch hours, a weekend and two holidays, all in the desk's own time zone. That's business-time arithmetic, and it turns up everywhere: support SLAs, payroll and overtime, delivery ETAs that only count operating hours, staff rosters.
I built workclock , an open-source library for it: one Rust core, published for Rust, Python and JavaScript. This post walks through the cases that make the problem harder than it looks, and how workclock handles each one.
Why another library
I'd worked on this kind of problem before, with shifts that run past midnight. In Python, the usual library for it is businesstimedelta. Its last release, 1.0.1, came out in September 2019, and several of its bugs are still open.…