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, 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)

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
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.1.2.tar.gz (5.8 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.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_datetime_kit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a3de51d06cfac61c71481db01d783f2f8168be6e555a17772e4cbe99b232be4b
MD5 536edc4554bd8a0728dbee1ef1d7aba3
BLAKE2b-256 56fd0fe4d82388c3776f211e4cfb676073bb9bad17ce3ed57c29660c6eff6a0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_datetime_kit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8bac9e644348a9500ba906b4da2db05b3499474c12b25ce624341f10b2403a3
MD5 167037c7deb0b94e2bfaada02f8e7dc8
BLAKE2b-256 5f16591dcc18fb8a06a02b5f4b336fb6083a7f537b34156ac7542b37dab9603e

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