businesslen
Overview
This Python package calculates the business hours/days* between two datetimes. It is possible to customize the work week schedule and list of holidays.
The default work week schedule is 9 AM to 5 PM, Monday to Friday, with a lunch break from 12 PM to 1 PM. The default holiday schedule is US from the package holidays.
* Business days are eight-hour workday.
Installation
pip install businesslen
Usage
from datetime import datetime
from businesslen import BusinessLen
start_dt = datetime(2020, 2, 10, 8, 5, 12)
end_dt = datetime(2020, 2, 12, 16, 37, 28)
bl = BusinessLen()
bl.hours(start_dt, end_dt) # 20.62
bl.days() # 2.58
Documentation
def __init__(workweek_schedule, lunch_hour, offdays):
""""Keyword arguments:
workweek_schedule --
a dict that defines weekly work hours; has following format
{
0: (9, 17),
...
6: ()
}
The key is an int following datetime weekday() function where
Monday is 0 and Sunday is 6. The value is a tuple with two ints:
the start hour and the end hour in 24 hour format (0 to 23).
lunch_hour -- int
offdays -- either an ISO country code or tuple of datetime dates to be
considered as holidays
"""
def hours(self, start_dt, end_dt):
"""Return business hours.
Keyword arguments:
start_dt -- datetime object of start time
end_dt -- datetime object of end time
"""
def days(self):
"""Return business days."""
Off-hours are not not added. For example, if end_dt is 30 minutes past work
hours, those 30 minutes will be ignored.
Input verification is done upon object initialization and each calculation.
ValueError is raised with corresponding error message if something is wrong.
Metadata
Release files for businesslen 2.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| businesslen-2.5.0.tar.gz | 3.8 kB | Without provenance | Details for businesslen-2.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| businesslen-2.5.0-py3-none-any.whl | Python 3 | none | any | Details for businesslen-2.5.0-py3-none-any.whl |
Total release size: 9.0 kB
Release files / businesslen-2.5.0.tar.gz
| Download URL | businesslen-2.5.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
520a1e0aaa6121715d7747f96898b5f82150c0120ad14438632a6716b5cd6943
|
|
BLAKE2b-256 checksum How to use checksums |
aecff6ae0901d5bc7a1be360b9760820e445dfbddeb4dd1a83dbd258e73bb771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
|
Release files / businesslen-2.5.0-py3-none-any.whl
| Download URL | businesslen-2.5.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bd580f6af28a24d24be00d7fd76c18797fb16d84c160d6de22aa9a06532bd69
|
|
BLAKE2b-256 checksum How to use checksums |
a628f10ec9ec3f88e8d52e8372161045b9737b65d5c64d5f4f8f93a617b6dd50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
|
Security for businesslen 2.5.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.