# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from datetime import time, timedelta from itertools import chain import pandas as pd from pandas.tseries.holiday import Holiday from pytz import timezone, UTC from calendars.common_holidays import (european_labour_day, new_years_day, WEEKDAYS, WEEKENDS) NewYearsDay = new_years_day() NationalSovereigntyAndChildrensDay = Holiday( "National Sovereignty and Children's Day", month=4, day=23, ) LabourDay = european_labour_day(start_date='2009') CommemorationOfAttaturkYouthAndSportsDay = Holiday( 'Commemoration of Attaturk, Youth and Sports Day', month=5, day=19, )
from pytz import timezone from calendars.common_holidays import ( new_years_day, anzac_day, christmas, boxing_day, ) # Prior to 2015, Waitangi Day and Anzac Day are not "Mondayized", # that is, if they occur on the weekend, there is no make-up. MONDAYIZATION_START_DATE = "2015-01-01" # Regular Holidays # ---------------- NewYearsDay = new_years_day(observance=next_monday) DayAfterNewYearsDay = Holiday( "Day after New Year's Day", month=1, day=2, observance=next_monday_or_tuesday, ) WaitangiDayNonMondayized = Holiday( "Waitangi Day", month=2, day=6, end_date=MONDAYIZATION_START_DATE, )
sunday_to_monday, weekend_to_monday, ) from pytz import timezone from pytz import UTC from calendars.common_holidays import ( new_years_day, anzac_day, christmas, weekend_christmas, boxing_day, weekend_boxing_day, ) NewYearsDay = new_years_day(observance=weekend_to_monday) AustraliaDay = Holiday( 'Australia Day', month=1, day=26, observance=weekend_to_monday, ) # Anzac Day was observed on Monday when it fell on a Sunday in # 2010 but that does not appear to have been the case previously. # We'll assume that this will be the behavior from now on. AnzacDayNonMondayized = anzac_day(end_date='2010') AnzacDay = anzac_day(observance=sunday_to_monday, start_date='2010') # When Easter Monday and Anzac Day coincided in 2011, Easter Tuesday was
---------- holidays : list[pd.tseries.holiday.Holiday] list of holidays dt : pd.Timestamp date of holiday. """ day_of_week = dt.weekday() if day_of_week == SUNDAY: while is_holiday_or_weekend(holidays, dt): dt += timedelta(1) return dt NewYearsHolidayJan1 = new_years_day() NewYearsHolidayJan2 = Holiday( "New Year's Holiday (Jan 2)", month=1, day=2, ) NewYearsHolidayJan3 = Holiday( "New Year's Holiday (Jan 3)", month=1, day=3, ) ComingOfAgeDay = Holiday( "Coming of Age Day", month=1,
def holidays(): return [ new_years_day(observance=sunday_to_monday, ), Holiday( "Human Rights Day", month=3, day=21, observance=sunday_to_monday, ), GoodFriday, Holiday( "Family Day", month=1, day=1, offset=[Easter(), Day(1)], ), Holiday( "Freedom Day", month=4, day=27, observance=sunday_to_monday, ), Holiday( "Workers' Day", month=5, day=1, observance=sunday_to_monday, ), Holiday( "Youth Day", month=6, day=16, observance=sunday_to_monday, ), Holiday( "National Women's Day", month=8, day=9, observance=sunday_to_monday, ), Holiday( "Heritage Day", month=9, day=24, observance=sunday_to_monday, ), Holiday( "Day of Reconciliation", month=12, day=16, observance=sunday_to_monday, ), Holiday( "Christmas", month=12, day=25, observance=sunday_to_monday, ), Holiday( "Day of Goodwill", month=12, day=26, observance=sunday_to_monday, ), ]
month=12, day=24, end_date=Timestamp('1993-01-01'), # When Christmas is a Saturday, the 24th is a full holiday. days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY), ) ChristmasEveInOrAfter1993 = Holiday( 'Christmas Eve', month=12, day=24, start_date=Timestamp('1993-01-01'), # When Christmas is a Saturday, the 24th is a full holiday. days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY), ) USNewYearsDay = new_years_day( # When Jan 1 is a Sunday, US markets observe the subsequent Monday. # When Jan 1 is a Saturday (as in 2005 and 2011), no holiday is observed. observance=sunday_to_monday) USMartinLutherKingJrAfter1998 = Holiday( 'Dr. Martin Luther King Jr. Day', month=1, day=1, # The US markets didn't observe MLK day as a holiday until 1998. start_date=Timestamp('1998-01-01'), offset=DateOffset(weekday=MO(3)), ) USMemorialDay = Holiday( # NOTE: The definition for Memorial Day is incorrect as of pandas 0.16.0. # See https://github.com/pydata/pandas/issues/9760. 'Memorial Day', month=5, day=25,