A Python library for managing holidays and days off.
Project description
Day Offs
Day Offs is a Python library that helps manage holidays and days off.
Features
- Manage weekly off days
- Get holidays for a country by locale
- Manage religious holidays
- Add additional holidays
Installation
You can install this library using pip
. To do that, run the following command in your terminal:
pip install dayoffs
Usage
from dayoffs.holiday_manager import HolidayManager
from datetime import datetime
def main():
# Initialize HolidayManager
holiday_manager = HolidayManager(
weekly_off_days=[
"saturday",
"sunday",
], # assuming you're using lowercase day names consistently,
# when providing the day names, be consistent in using either all lowercase or all title case
religious_holidays=["christian"],
country_locale="US",
additional_holidays=[datetime(2023, 12, 31), datetime(2023, 1, 1)],
)
# Get all holidays
all_holidays = holiday_manager.get_holidays()
print(f"All holidays: {all_holidays}")
# Check a specific date for holiday
is_holiday = holiday_manager.is_holiday(date=datetime(2023, 12, 25))
print(f"Is Dec 25, 2023 a holiday? {'Yes' if is_holiday else 'No'}")
# Get holidays for a specific period
period_holidays = holiday_manager.get_holidays(
start_date=datetime(2023, 1, 1), end_date=datetime(2023, 12, 31)
)
print(f"Holidays in 2023: {period_holidays}")
# check if a specific date is a weekly off day
is_weekly_off = holiday_manager.is_weekly_off(date=datetime.now())
print(
f"Is today ({datetime.now().today()}) a weekly off? {'Yes' if is_weekly_off else 'No'}"
)
if __name__ == "__main__":
main()
Testing
We use pytest for testing. To run the test suite, run the following command in the project root directory:
pytest
Or for a coverage report:
pytest --cov=./ --cov-report term-missing
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
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
dayoffs-0.0.1.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file dayoffs-0.0.1.tar.gz
.
File metadata
- Download URL: dayoffs-0.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 454203e20a10de5c26d7af1b47c95432f27d04b2ac136e327f74fe26d0a71d48 |
|
MD5 | c3e632d63f7f6edcd5c5ec68dabc3612 |
|
BLAKE2b-256 | 0d9e5f5c30bb6fdc352ac05059af90defa28fdb4846561cbebf3b118e68b916b |
File details
Details for the file dayoffs-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dayoffs-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0593117615b698e2cbe8df7c559c43f86d28acc06c39d59be8f1273d3ed92cd |
|
MD5 | d8849b225598107a1ad33bc73aee72f8 |
|
BLAKE2b-256 | f1f79517bf351558f95b5e24f08447d96fa60a53b44832e8f4a07d14b1093478 |