Module for performing simple business day arithmetic; forked from python-bizdatetime
Project description
ABOUT
bizdatim is a simple library for performing business day arithmetic.
Source is hosted at https://github.com/Polyconseil/bizdatim.
KNOWN LIMITATIONS
Rotating weekends/holidays are not supported (e.g., two days working, third day off).
The business hour arithmetic is limited to additions.
DEFINITIONS
- Weekend
Weekly repeating non-business day. Weekend does not have to be at the end (or beginning) or the week. Weekends do not have to be consecutive days.
- Holiday
Like weekend, holiday is a non-business day. Unlike weekend, holiday does not have weekly regularity. It is just a date. Holiday can coincide with weekend.
- Working hours
The starting and ending time of a business day.
- Policy
Is a (possibly empty) collection of weekends, holidays and working hours. All calculations are performed within a policy.
SAMPLE USAGE
All business day arithmetic is performed in the context of policy:
>>> from bizdatim import Polycy, SAT, SUN >>> from datetime import date >>> policy = Policy(weekends=(SAT, SUN), holidays=(date(2011,7,1),)) >>> day = date(2011, 6, 29) # Wednesday >>> print(policy.add(day, 2)) # add 2 business dates -> Monday after the long weekend datetime.date(2011, 7, 4) >>> print(policy.biz_day_delta(date(2011, 7, 4), date(2011, 6, 30))) # one holiday, one weekend between 1
There is also the possibility to do arithmetic on business hours:
>>> policy = Policy(weekends=(SAT, SUN), holidays=(date(2011,7,1)), hours=(time(8), time(20))) >>> day = datetime(2011, 6, 29, 14, 30) >>> policy.add(day, timedelta(days=1, hours=5)) # The day after, in the afternoon datetime.datetime(2011, 6, 29, 19, 30) >>> policy.add(day, timedelta(days=1, hours=10)) # Too many hours, will finish the monday after the long weekend datetime.datetime(2011, 7, 4, 12, 30)
Policy method docstrings contain more examples.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file bizdatim-0.2.0.tar.gz
.
File metadata
- Download URL: bizdatim-0.2.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f34c814aee9a4cb74e00fe9e3b8f9d943f6b877579c4495abd39cc58ebcd6e7 |
|
MD5 | cc335e22641b34abe06814573dc9828c |
|
BLAKE2b-256 | cbfe742dd9ac52ccccef6105449861b7d64da2a9c97414a52a64dc64d38e487a |
File details
Details for the file bizdatim-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: bizdatim-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e2bbff3f56529e3f70d868df6f3415e6e4e1e1b751367124099a2d9002a3c24 |
|
MD5 | bcca2f3e3b629e40797c31b88acda2c4 |
|
BLAKE2b-256 | 960ca0b3fea7362f5ceddf1f78ac626905e5ebef41dde02cdac112462ac1de9e |