A simple Python helper class to determine Italian holidays with the possibility to set custom holidays.
Project description
ItalianHolidays
A simple Python helper class to determine Italian holidays with the possibility to set custom holidays. Easter holidays' calculation will work for dates between 1900-2199.
Install
Using Pip
pip install italian-holidays
Usage
from italian_holidays import italian_holidays
from datetime import datetime
custom_holidays = ["01-03", "01-05"] # date format: month-day | in this example: 3 January, 5 January
# But accepts also array of datetime object
custom_holidays = [datetime(2021, 1, 3), datetime(2021, 1, 5)]
holidays = italian_holidays(custom_holidays) # or simply italian_holidays() if you have no custom holidays to set
# Passing string
is_holiday = holidays.is_holiday("2024-01-03")
print(is_holiday) # True
# Passing datetime object
day = datetime(2031, 4, 14)
is_holiday = holidays.is_holiday(day)
print(is_holiday) # True
# Getting holiday's name (return None if date is not an italian holiday, return 'Custom holiday' if is one of the given dates)
holiday_name = holidays.holiday_name("2020-11-01")
print(holiday_name) # All Saints' Day
Licence
Source code can be found on github, licenced under MIT.
Developed by Giuseppe Bruno
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
italian-holidays-0.0.4.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for italian_holidays-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2a426838df5e5d5f874ca105f7232332f785f58b8d2b7f814e4924ebfaef17c |
|
MD5 | 7fa5cf745d5fbb56419785094b9d827d |
|
BLAKE2b-256 | f9df5efd5e4601b1c594cbdbb83fa6a71f942572ba16c2ccc4cc9ee0660a8213 |