Skip to content
Browse files

Prevent invalid month error in days calculation

  • Loading branch information...
1 parent 5bab03f commit e4cd553964d189c916c2e1b51c347dfd791a415b @meldra committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 brain/views.py
View
7 brain/views.py
@@ -198,11 +198,12 @@ def index(request, year=0, month=0, day=0):
year = int(year)
days = False
- if month > 0 and year > 0:
+ if month > 0 and month <= 12 and year > 0:
days = calendar.monthrange(year, month)
- if days != False and day > 0 and day <= days[1]:
+
+ if days and day > 0 and day <= days[1]:
dayCal = singleday(year, month, day)
- elif month > 0 and month <= 12:
+ elif month > 0 and month <=12:
monthCal = cal.formatmonth(year, month)
nextmonth = month+1
prevmonth = month-1

0 comments on commit e4cd553

Please sign in to comment.
Something went wrong with that request. Please try again.