@@ -2811,10 +2811,22 @@ def html_calendar(self, request):
28112811 day = display .day
28122812
28132813 # for navigation
2814- date_prev_month = display + date .Interval ("-1m" )
2815- date_next_month = display + date .Interval ("+1m" )
2816- date_prev_year = display + date .Interval ("-1y" )
2817- date_next_year = display + date .Interval ("+1y" )
2814+ try :
2815+ date_prev_month = display + date .Interval ("-1m" )
2816+ except ValueError :
2817+ date_prev_month = None
2818+ try :
2819+ date_next_month = display + date .Interval ("+1m" )
2820+ except ValueError :
2821+ date_next_month = None
2822+ try :
2823+ date_prev_year = display + date .Interval ("-1y" )
2824+ except ValueError :
2825+ date_prev_year = None
2826+ try :
2827+ date_next_year = display + date .Interval ("+1y" )
2828+ except ValueError :
2829+ date_next_year = None
28182830
28192831 res = []
28202832
@@ -2826,19 +2838,31 @@ def html_calendar(self, request):
28262838 res .append ('<table class="calendar"><tr><td>' )
28272839 res .append (' <table width="100%" class="calendar_nav"><tr>' )
28282840 link = "&display=%s" % date_prev_month
2829- res .append (' <td><a href="%s&display=%s"><</a></td>' % (base_link ,
2830- date_prev_month ))
2841+ if date_prev_month :
2842+ res .append (' <td><a href="%s&display=%s"><</a></td>'
2843+ % (base_link , date_prev_month ))
2844+ else :
2845+ res .append (' <td></td>' )
28312846 res .append (' <td>%s</td>' % calendar .month_name [display .month ])
2832- res .append (' <td><a href="%s&display=%s">></a></td>' % (base_link ,
2833- date_next_month ))
2847+ if date_next_month :
2848+ res .append (' <td><a href="%s&display=%s">></a></td>'
2849+ % (base_link , date_next_month ))
2850+ else :
2851+ res .append (' <td></td>' )
28342852 # spacer
28352853 res .append (' <td width="100%"></td>' )
28362854 # year
2837- res .append (' <td><a href="%s&display=%s"><</a></td>' % (base_link ,
2838- date_prev_year ))
2855+ if date_prev_year :
2856+ res .append (' <td><a href="%s&display=%s"><</a></td>'
2857+ % (base_link , date_prev_year ))
2858+ else :
2859+ res .append (' <td></td>' )
28392860 res .append (' <td>%s</td>' % display .year )
2840- res .append (' <td><a href="%s&display=%s">></a></td>' % (base_link ,
2841- date_next_year ))
2861+ if date_next_year :
2862+ res .append (' <td><a href="%s&display=%s">></a></td>'
2863+ % (base_link , date_next_year ))
2864+ else :
2865+ res .append (' <td></td>' )
28422866 res .append (' </tr></table>' )
28432867 res .append (' </td></tr>' )
28442868
0 commit comments