Calendar.inverse¶
- Calendar.inverse(starting: date = None, ending: date = None)¶
Returns a calendar with all dates between
startingandending, excluding any days in this calendar.- Parameters:
starting (datetime.date) – the starting date of the new calendar (defaults to
calendar[0])ending (datetime.date) – the ending date of the new calendar (defaults to
calendar[-1])
- Returns:
Inverse of this calendar
- Return type:
Example
Compute the open weekdays in 2022 from a list of holidays
>>> import datetime >>> holidays = [ ... datetime.date(2022, 1, 17), ... datetime.date(2022, 5, 30), ... datetime.date(2022, 6, 4), ... datetime.date(2022, 9, 5), ... datetime.date(2022, 11, 11), ... datetime.date(2022, 12, 24), ... datetime.date(2022, 12, 26) ... ] >>> calendar = dtwo.Calendar(holidays).inverse( ... datetime.date(2022,1,1), datetime.date(2022, 12, 31) ... ).weekdays()