本文整理汇总了Python中calendar.Calendar.yeardayscalendar方法的典型用法代码示例。如果您正苦于以下问题:Python Calendar.yeardayscalendar方法的具体用法?Python Calendar.yeardayscalendar怎么用?Python Calendar.yeardayscalendar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendar.Calendar
的用法示例。
在下文中一共展示了Calendar.yeardayscalendar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: events_source_in_year
# 需要导入模块: from calendar import Calendar [as 别名]
# 或者: from calendar.Calendar import yeardayscalendar [as 别名]
def events_source_in_year(self, request, pk, format=None):
"""
Lista los eventos de una source durante el año actual
:param request:
:param pk:
:param format:
:return:
"""
calendary = Calendar(0)
today = timezone.localtime(timezone.now())
list_month_year = []
year = today.year
try:
events_in_year = Events.objects.filter(ID_Source=pk)
except Events.DoesNotExist:
return HttpResponse(status=404)
calendary_year = calendary.yeardayscalendar(today.year)
# Esta variable almacena la información en 4 listas de la siguiente manera:
# - Primera lista: 3 meses del año (Empezando en Enero)
# - Segunda lista: 1 mes completo dividido en 4-6 listas de semanas (lista que se pasa a la funcion interna
# de la clase events_source_in_month)
# - Tercera lista: dias del mes por semana
# - Cuarta lista: dias de la semana
count_month = 0
for it in calendary_year:
for it_month in it:
count_month += 1
dict_year = {'pk': pk, 'list_month': it_month, 'year': year, 'month': count_month,
'events_db': events_in_year}
list_month_year.append(EventsInformation().events_source_in_month(request, dict_year))
result = []
count = 0
for it in list_month_year:
count += 1
result.append({'month': count, 'weeks': it})
print "RESULT: ", result
return JSONResponse(result)