def get_days_of_the_month(month, year = date.today().year):
#get current year
if year is None:
year = date.today().year
mappings = {_('January'): 1, _('February'): 2, _('March'): 3, _('April'): 4, _('May'): 5, _('June'): 6, _('July'): 7
, _('August'): 8, _('September'): 9, _('October'): 10, _('November'): 11, _('December'): 12}
c = calendar.Calendar()
days = c.itermonthdays(int(year), mappings[_(month)])
days_set = set()
for day in days:
days_set.add(day)
days_set.remove(0) #because 0 is not aan actual day from that month
return days_set
评论列表
文章目录