Calculate Business days (workdays) between two date, like `NetworkDays` function used on spreadsheets. Schedule based on hours and business days
Project description
A lean and powerful Python library for business day calculations and schedule
No dependencies, just Python. Simple, fast, and efficient
some statistics …
Pypi Version |
Doc Status |
Coverage |
Downloads |
|---|---|---|---|
Tired of heavy libraries for simple date calculations?
networkdays is the solution you’ve been looking for. A pure Python library, with no dependencies, to calculate business days between dates, quickly and efficiently. Ideal for Python developers and data scientists who value simplicity and performance.
Why choose networkdays?
🚀 Lightweight and Fast: Without the weight of external dependencies. Perfect for microservices, scripts, and projects where every millisecond counts.
🧘♀️ Simple and Intuitive: A clear and straightforward API that resembles the spreadsheet functions you already know.
💪 Flexible and Powerful: Support for custom holidays and days off, adapting to any calendar.
📅 Project Planning: Calculate work schedules based on effort hours and business days.
Get started now!
Install networkdays with pip and start simplifying your date calculations today.
pip install python-networkdays
Practical Examples
Calculate business days between two dates
Just like in your favorite spreadsheet, calculate the working days, disregarding weekends and holidays.
from datetime import date
from networkdays import Networkdays
# Define the holidays
HOLIDAYS = {date(2024, 12, 25), date(2025, 1, 1)}
# Create a Networkdays instance
workdays = Networkdays(
date(2024, 12, 20), # Start date
date(2025, 1, 10), # End date
HOLIDAYS # List of holidays
)
# Get the list of workdays
day_list = workdays.networkdays()
print(f"There are {len(day_list)} working days.")
# There are 14 working days.
# You can also list the weekends and holidays in the period
print(f"Holidays: {workdays.holidays()}")
# Holidays: [datetime.date(2024, 12, 25), datetime.date(2025, 1, 1)]
print(f"Weekends: {workdays.weekends()}")
# Weekends: [datetime.date(2024, 12, 21), datetime.date(2024, 12, 22), ... ]
Plan your Project
Estimate the end date of a project based on working hours.
from datetime import date
from networkdays import JobSchedule
# Plan a 120-hour project, with 8 working hours per day,
# starting on July 1, 2024.
schedule = JobSchedule(
project_duration_hours=120,
workhours_per_day=8,
date_start=date(2024, 7, 1)
)
print(f"The project will take {schedule.bussines_days} business days.")
# The project will take 15 business days.
print(f"Starts on: {schedule.prj_starts}")
# Starts on: 07/01/24
print(f"Ends on: {schedule.prj_ends}")
# Ends on: 07/19/24
# Analyze the work distribution
print(f"Project years: {list(schedule.years())}")
# Project years: [2024]
print(f"Project months: {list(schedule.months())}")
# Project months: [7]
Total Flexibility
Work on Saturdays? No problem. networkdays adapts to your needs.
from datetime import date
from networkdays import Networkdays
# Consider only Sunday as a day off (1=Mon, 7=Sun)
saturday_workdays = Networkdays(
date(2024, 7, 1),
date(2024, 7, 31),
weekdaysoff={7} # Only Sundays
)
print(f"Working days in July (working on Saturdays): {len(saturday_workdays.networkdays())}")
# Working days in July (working on Saturdays): 27
Complete Documentation
For more details and examples, access our official documentation:
Contributions
Contributions are always welcome! Feel free to open an issue or submit a pull request.
Code of Conduct
Everyone interacting with the project must follow our Code of Conduct.
License
This project is licensed under the MIT license. See the LICENSE file for more details.
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 python_networkdays-1.2.tar.gz.
File metadata
- Download URL: python_networkdays-1.2.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dda9f5603a0464a00612fdd2f2939f6d410c2432a2cad6843a93828953774ba5
|
|
| MD5 |
af99c3518394bd5a5f9feb411210d2e6
|
|
| BLAKE2b-256 |
3f7775f985d06c9ea2ef48bd0f687056bc89981fc21ad3704bb614d1223a601b
|
File details
Details for the file python_networkdays-1.2-py3-none-any.whl.
File metadata
- Download URL: python_networkdays-1.2-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53843a8650885c30e87a1c37107148a82ab38276c613ac92c94face9e35925dd
|
|
| MD5 |
cfbfc3500e693af37acf16f39ba37859
|
|
| BLAKE2b-256 |
3d41a5c0add60e3c2ee0f951d7ee959ab31da766b57fef00a37f13a5673f9a5b
|