Skip to main content

workclock

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.

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.3

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.3
File Size Uploaded Provenance Actions
workclock-0.1.3.tar.gz 47.6 kB With provenance Details for workclock-0.1.3.tar.gz

Built distributions (wheels)

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

Total release size: 4.2 MB

Release files / workclock-0.1.3.tar.gz

Download URL workclock-0.1.3.tar.gz
Size 47.6 kB
Tags Source
SHA-256 checksum
How to use checksums
88ac759f048ca4306c26e4f06aefdda43c7203c62f41859ac3060575491c5b19
BLAKE2b-256 checksum
How to use checksums
2a50b73a25ef394eb76f3afe25479362c4267b9a257cd41551393fa27a318c4a
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.3-cp39-abi3-win_amd64.whl

Download URL workclock-0.1.3-cp39-abi3-win_amd64.whl
Size 411.7 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a1a3ad6f36db6b7bbc9a606301e1d996a07b0ad3f57643b2bdb3a76e3833b173
BLAKE2b-256 checksum
How to use checksums
280ed4590abe41240eedbd15d62145fe92d8e660ccd62e6e799943cae92ec606
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.3-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL workclock-0.1.3-cp39-abi3-musllinux_1_2_x86_64.whl
Size 782.4 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
158817d2735809359c0f38d1a26e3665710e61eb145e5e916aa0b51cd5737abc
BLAKE2b-256 checksum
How to use checksums
c41adc851472fe4e4907d09a744ff56b42993d04316daf8c60c6217b6a0f40cb
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.3-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL workclock-0.1.3-cp39-abi3-musllinux_1_2_aarch64.whl
Size 759.5 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
c47f6a6ba9bf8a26285644519c39b976b8ae1bc2e835ce82836aaa87c970af9f
BLAKE2b-256 checksum
How to use checksums
cc0268fe3602f31360ec834933af4c4f09a65aa75595e72707790e9190bb8df5
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.3-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL workclock-0.1.3-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 576.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3e9b3a8403cf3956017299441179271588f62e347459d469bf146b72122f525a
BLAKE2b-256 checksum
How to use checksums
155e3e26039b9dedf43bba6e758986c7bcbd2ddcdcc1637744eaa543b0262417
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.3-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL workclock-0.1.3-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 580.3 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8c1bcb72bc37a93f772fae3bea350f16822f998f9d473ee9b28584afae8768b9
BLAKE2b-256 checksum
How to use checksums
8e97439f54a5c04c825bac434426552a4581b1b4d4de2eec4e2000bc099be4e8
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.3-cp39-abi3-macosx_11_0_arm64.whl

Download URL workclock-0.1.3-cp39-abi3-macosx_11_0_arm64.whl
Size 528.4 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d9c3fbe508c2e0e6c367259d7233d1dd46a25639cfe16f3f079ca1c7d1046b8
BLAKE2b-256 checksum
How to use checksums
69c58693ca9fc795a3e634e5efcdef6ecfe679aad925963f9b153ad42ea3e677
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.3-cp39-abi3-macosx_10_12_x86_64.whl

Download URL workclock-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl
Size 518.1 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2c2b61f8ba20ac263e9578cc4c8dc9a1a6dcb2b69965640c18ac679a1761e947
BLAKE2b-256 checksum
How to use checksums
15150a70f6b2fb87be032a68676a78c0a1b9d1744d2cc3dbf57caf24a8df720d
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.3

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.3.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