Skip to main content

Common datetime operations missing from the standard library.

Project description

philiprehberger-datetime-kit

Tests PyPI version Last updated

Common datetime operations missing from the standard library.

Installation

pip install philiprehberger-datetime-kit

Usage

from philiprehberger_datetime_kit import business_days, date_range, is_weekend, relative

# Count business days between two dates
count = business_days("2026-03-16", "2026-03-20")  # 4

Business Days with Holidays

from philiprehberger_datetime_kit import business_days

count = business_days("2026-03-16", "2026-03-20", holidays=["2026-03-18"])  # 3

Date Range

from philiprehberger_datetime_kit import date_range

for d in date_range("2026-03-01", "2026-03-05"):
    print(d)

Relative Time

from philiprehberger_datetime_kit import relative

tomorrow = relative(days=1)
one_hour_ago = relative(hours=-1)

Weekend Check

from philiprehberger_datetime_kit import is_weekend

is_weekend(date(2026, 4, 4))  # True (Saturday)
is_weekend(date(2026, 4, 6))  # False (Monday)

Next Business Day

from philiprehberger_datetime_kit import next_business_day
from datetime import date

next_business_day(date(2026, 4, 3))  # date(2026, 4, 6) — skips weekend
next_business_day(date(2026, 4, 3), holidays=[date(2026, 4, 6)])  # date(2026, 4, 7)

Start and End of Period

from philiprehberger_datetime_kit import start_of, end_of

start = start_of("month")   # first moment of current month
end = end_of("day")         # last moment of today

API

Function Description
business_days(start, end, holidays?) Count business days (Mon-Fri) between two dates
date_range(start, end, step?) Yield dates from start to end inclusive
is_weekend(dt?) Check if a date falls on a weekend
next_business_day(dt?, holidays?) Return the next business day (Mon-Fri, excluding holidays)
relative(days?, hours?, minutes?, seconds?) Return UTC now offset by the given delta
start_of(unit, dt?) Start of day/week/month/year
end_of(unit, dt?) End of day/week/month/year

Development

pip install -e .
python -m pytest tests/ -v

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

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

philiprehberger_datetime_kit-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_datetime_kit-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_datetime_kit-0.2.0.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_datetime_kit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7d63e61d900ed82522701d8416986d78a5b8cd59261ec08521a06d1100484a4e
MD5 296ea79eede24101faf8e4f8c6814cb2
BLAKE2b-256 e1b5fb872c35ec74c9dc7b9506511651e03519273d81f76f7489fada0b277783

See more details on using hashes here.

File details

Details for the file philiprehberger_datetime_kit-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_datetime_kit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e91425cc3e81f2eabf04ecd5bcd18732e45760d74ff705bf705a6805bc563eb6
MD5 ff48fdcfb18c207517bf5b59587f56d5
BLAKE2b-256 9f83f7b0be8a691b4e73cf0dfcab7f7d84d89ba2e0eeb3910936b47f5998bd23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page