Skip to main content

workclock

CI PyPI Python versions Typed License: MIT

Fast, correct business-time arithmetic (working hours, SLAs, shifts) for Python, with a Rust core — a maintained replacement for businesstimedelta, with a compatibility layer for existing code.

Documentation · Python reference · Playground · Migrating from businesstimedelta

Status: pre-1.0; the API may still change in a minor release.

Install

pip install workclock
uv add workclock

Requires CPython 3.9 or later. The wheels use the stable ABI (abi3), one per platform: Linux x86_64 and aarch64 (manylinux and musllinux), macOS x86_64 and arm64, and Windows x64. Free-threaded CPython cannot load abi3 wheels. Other platforms build from the sdist, which needs a Rust toolchain.

The wheels bundle the IANA time zone database. They use the system database when there is one, and the bundled copy otherwise, so they need no tzdata package.

Quickstart

A support desk in London works 09:00–17:00 on weekdays with a lunch hour, and is closed on 25 and 28 December 2026. A ticket opened at 16:30 on Christmas Eve with an 8-hour SLA is due at 09:30 on 30 December.

from datetime import date, datetime, time
from zoneinfo import ZoneInfo

from workclock import Break, Holidays, Schedule, WorkDay

london = ZoneInfo("Europe/London")
support = Schedule(
    [
        WorkDay(time(9), time(17)),  # Monday to Friday by default
        Break(time(12), time(13)),
        Holidays([date(2026, 12, 25), date(2026, 12, 28)]),
    ],
    time_zone=london,
)

opened = datetime(2026, 12, 24, 16, 30, tzinfo=london)
support.add(opened, hours=8)  # 2026-12-30 09:30, London time
support.between(opened, datetime(2026, 12, 29, 11, tzinfo=london))  # 2:30:00
support.next_period(opened)  # (16:30, 17:00) on 24 December

Datetimes must be timezone-aware, and results keep the tzinfo you pass in. Zones can be IANA names, zoneinfo.ZoneInfo, pytz zones or datetime.timezone.utc. Errors subclass workclock.WorkclockError and the matching built-in exception.

Batches and NumPy

between_many, add_many and sub_many take lists of datetimes, or NumPy datetime64 and timedelta64 arrays, and process them in one call:

from datetime import datetime, time, timedelta, timezone

from workclock import Schedule, WorkDay

office = Schedule([WorkDay(time(9), time(17))])
tickets = [datetime(2026, 1, 5, 16, tzinfo=timezone.utc)] * 3
office.add_many(tickets, timedelta(hours=2))  # Tuesday 10:00, three times

Coming from businesstimedelta

Most code written for businesstimedelta runs unchanged on workclock's engine:

import datetime

import workclock.compat as businesstimedelta

rule = businesstimedelta.WorkDayRule(datetime.time(9), datetime.time(17))
friday = datetime.datetime(2026, 1, 9, 16)
friday + businesstimedelta.BusinessTimeDelta(rule, hours=2)  # Monday 10:00 UTC

MIGRATING.md lists where it differs.

Why workclock

Correct

businesstimedelta 1.0.1 has had no release since 2019. workclock fixes:

  • Overnight shifts. A 22:00–06:00 shift counts 0 hours between Monday 22:00 and Tuesday 06:00, and adding 4 hours at Monday 22:00 lands on Wednesday. workclock gives 8 hours and Tuesday 02:00.
  • Crashes past the last holiday (#8, #10): TypeError once a query passes the last date in a holiday list.
  • Infinite loops (#9) when holidays and working hours use different time zones. Every workclock search is bounded.
  • Signed differences (#12): Schedule.between(a, b) is negative when b is before a.
  • DST. Working hours are wall-clock times in each rule's IANA zone, and ambiguous or skipped times resolve the way RFC 5545 and JavaScript Temporal do.

Every rule is specified with examples in DESIGN.md, and the package is checked against a brute-force oracle with property-based tests.

Fast

Medians from a GitHub Actions run on a GitHub-hosted Ubuntu runner (AMD EPYC 7763, 4 cores), against businesstimedelta 1.0.1 and against a loop written by hand for this one schedule with datetime and zoneinfo:

Case businesstimedelta 1.0.1 Standard library workclock vs businesstimedelta vs standard library
One call, a 5½-hour span 169 µs 4.01 µs 3.96 µs 43× 1×
One call, a year with bank holidays 53 ms 719 µs 85.4 µs 620× 8.4×
1,000,000 pairs 9.9 min 9.95 s 2.13 s (between_many on NumPy arrays) 280× 4.7×

For one short span the hand-written loop keeps up: most of workclock's call goes on converting datetimes into and out of Rust. workclock pulls ahead as spans get longer or calls are batched. The loop also handles only this one schedule, without overnight shifts or per-rule time zones.

The same single call takes 7.24 µs through workclock.compat. Runner CPUs vary, so the times move from run to run; the speed-ups, measured within one run, carry over better. benchmarks/RESULTS.md has every case with p95s.

Also for Rust and JavaScript

The same engine ships as the workclock crate and the workclock npm package, with the same results in every language.

Prior art & credits

workclock ports the test suite and the API of businesstimedelta by Sebastiaan Boer, released under the MIT license. The ported API is workclock.compat, and the ported tests run against it in CI. The original copyright notice is kept in NOTICE.

License

MIT

Metadata

Release files for workclock 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for workclock 0.1.4
File Size Uploaded Provenance Actions
workclock-0.1.4.tar.gz 48.4 kB With provenance Details for workclock-0.1.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for workclock 0.1.4
File Actions
workclock-0.1.4-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for workclock-0.1.4-cp39-abi3-win_amd64.whl
workclock-0.1.4-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for workclock-0.1.4-cp39-abi3-musllinux_1_2_x86_64.whl
workclock-0.1.4-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for workclock-0.1.4-cp39-abi3-musllinux_1_2_aarch64.whl
workclock-0.1.4-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for workclock-0.1.4-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
workclock-0.1.4-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for workclock-0.1.4-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
workclock-0.1.4-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for workclock-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
workclock-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for workclock-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 4.2 MB

Release files / workclock-0.1.4.tar.gz

Download URL workclock-0.1.4.tar.gz
Size 48.4 kB
Tags Source
SHA-256 checksum
How to use checksums
38ae1ed89ca339ecb176feb2d57a27b754f44d7f0d9fab6caef4eab48f0f7fac
BLAKE2b-256 checksum
How to use checksums
a5264a5b0132ded89d6c1d4c117ec1038aea83b944b16757cead41aa4832e0a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-win_amd64.whl

Download URL workclock-0.1.4-cp39-abi3-win_amd64.whl
Size 411.9 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
09e5ad6ab4c08ac9a079cd97722115bbe991cf27505dcc2b02f0ad7e771a93c8
BLAKE2b-256 checksum
How to use checksums
1c1efbbfcdaa9559f9b4b05c36f25428749e76774f032eb197fe629ec66ec409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL workclock-0.1.4-cp39-abi3-musllinux_1_2_x86_64.whl
Size 782.8 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
8d9196463e9e2cc099158743694b5f08778d12563a019c7691ce7bb687c163b7
BLAKE2b-256 checksum
How to use checksums
7c02b2986b6198a818daf1f9987807fca0e7cdc70d549a5e549c427c0f88b5c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL workclock-0.1.4-cp39-abi3-musllinux_1_2_aarch64.whl
Size 759.1 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2fdcedee61bcaf06a7f1f9eeed1d420d1d50806206caa2ac93660b58719ca418
BLAKE2b-256 checksum
How to use checksums
82564a94113fae70ee1b0620259bee758602f3746d5fbf96e3bd32ec486cf075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL workclock-0.1.4-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 577.2 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
22ad3c15c15944bf37dbca053a4cdd6b897ffc3f95227b918dfb196a60561eb4
BLAKE2b-256 checksum
How to use checksums
4c4b77b5d3c40b5394de1b63da42ad7adaf6f25b195c26283030b34c43a0c038
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL workclock-0.1.4-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 580.6 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d8322bccbe7edafbb44e3c6ab3db4cf75109cac1d91b9c4aacd9996875bc9107
BLAKE2b-256 checksum
How to use checksums
8bd114b20e0f96fc3c183afc3f9f6fa8a9ec54bfaf22070999a1a86ceca55216
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-macosx_11_0_arm64.whl

Download URL workclock-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Size 528.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
00b8b4acaf21b5b503b75cc2b08a7251a34f7dd3eae67a229a7c26f2de946f0b
BLAKE2b-256 checksum
How to use checksums
48fccfa85be0a5f1f24d89737646109c8c4d0b9784429c4037a5ba68aca2d224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / workclock-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl

Download URL workclock-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl
Size 518.3 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d044a9e56bbe0d8671ab2a1a286ba77c6554e004a63d0647ebf764c67498e7b7
BLAKE2b-256 checksum
How to use checksums
d66a1dc435bd12d7420fc61ff6d7252a910276d1788cdc6c6d17f9c28055f00c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for workclock 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for workclock-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page