A lightweight, flexible business duration calculator.
Project description
bizdurr
A lightweight, flexible business duration calculator
Calculate the amount of time that falls within your defined business hours — accounting for weekly schedules, holidays, and per-date overrides.
Installation
uv add bizdurr
Or with pip:
pip install bizdurr
Or install from source:
git clone https://github.com/patclrk/bizdurr.git
cd bizdurr
uv pip install .
Quick Start
from datetime import datetime
from bizdurr import BusinessDuration
# Define your weekly business hours
schedule = {
"monday": {"start": "09:00", "end": "17:00"},
"tuesday": {"start": "09:00", "end": "17:00"},
"wednesday": {"start": "09:00", "end": "17:00"},
"thursday": {"start": "09:00", "end": "17:00"},
"friday": {"start": "09:00", "end": "17:00"},
}
# Create a BusinessDuration instance
bd = BusinessDuration(
business_hours=schedule,
timezone="America/New_York",
)
# Calculate the business duration between two datetimes
start = datetime(2025, 12, 8, 8, 0) # Monday 8:00 AM
end = datetime(2025, 12, 8, 18, 0) # Monday 6:00 PM
duration = bd.calculate(start, end)
print(duration) # 8:00:00 (8 hours of business time)
type(duration) # <class 'datetime.timedelta'>
Features
Weekly Schedule
Pass a dict mapping weekday names (case-insensitive) to start/end times in HH:MM 24-hour format:
schedule = {
"monday": {"start": "09:00", "end": "17:00"},
"tuesday": {"start": "10:00", "end": "16:00"},
# ...
}
Shorthand Schedule (Monday–Friday)
For a fixed Monday through Friday schedule, use the shorthand format:
bd = BusinessDuration(
business_hours={"start": "09:00", "end": "17:00"}, # Expands to Mon-Fri
timezone="America/New_York",
)
This automatically expands to Monday through Friday with the same hours. Weekend days (Saturday and Sunday) are excluded.
Holidays
Exclude specific dates from business hours:
bd = BusinessDuration(
business_hours=schedule,
timezone="America/New_York",
holidays=["2025-12-25", "2026-01-01"], # ISO date strings or date objects
)
Per-Date Overrides
Override business hours for specific dates (e.g., early close):
bd = BusinessDuration(
business_hours=schedule,
timezone="America/New_York",
overrides={
# Christmas Eve: half day
"2025-12-24": {"start": "09:00", "end": "12:00"},
},
)
Timezone Support
All times are interpreted in the specified IANA timezone:
bd = BusinessDuration(
business_hours=schedule,
timezone="Europe/London",
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bizdurr-1.0.2.tar.gz.
File metadata
- Download URL: bizdurr-1.0.2.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67739af8f84eb4abd5b4bdb17b9902cb6a4f5aa347958e07063d58ff3283d2d4
|
|
| MD5 |
2e1d8784ffd585c964699d22f4d949e2
|
|
| BLAKE2b-256 |
65824c21bc5565f0bcf47c01faf98616274caa97f96f6ee1b5a0c3bdb38704d1
|
File details
Details for the file bizdurr-1.0.2-py3-none-any.whl.
File metadata
- Download URL: bizdurr-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd8ca000e914421669a4f1fc0aa9f0e4d6e60c993a2e032f92a0f57f5585ce8e
|
|
| MD5 |
4b8f782f5cc3a58ce383b4981746fc7b
|
|
| BLAKE2b-256 |
75dd204b957431f82206f64b50371d190155a383cecb4e594a588d3974f04314
|