user3333155
user3333155

Reputation: 101

workalendar.europe library: how to find holidays

I'm trying to get the holiday name passing the date in workalendar.europe library but I have no results

form workalendar.europe import France
cal._holidays.get(datetime.date(2015, 1, 1))

Upvotes: 2

Views: 1947

Answers (1)

falsetru
falsetru

Reputation: 368894

Using workalendar.core.Calendar.holidays which returns a list of (date, holiday) pairs:

>>> import datetime
>>> from workalendar.europe import France
>>> cal = France()
>>> d = datetime.date(2015, 1, 1)
>>> holiday_map = dict(cal.holidays(d.year))  # list -> dict
>>> holiday_map.get(d, '?')
'New year'

Upvotes: 1

Related Questions