def monthly_checkins(year_num, month_num, user):
month_range = calendar.monthrange(year_num, month_num)
month = [False] * month_range[1]
start_of_month = datetime.date(year_num, month_num, 1)
checkins = Checkin.query.filter(Checkin.user==user, Checkin.checkin_timestamp>=start_of_month).order_by('Checkin.checkin_timestamp')
for checkin in checkins:
if checkin.checkin_timestamp.date().month == month_num:
if checkin.checkin_timestamp.date().year == year_num:
month[checkin.checkin_timestamp.date().day - 1] = True
return month
评论列表
文章目录