Calendar Popup: Fix prev/next year for shorter February Patch by Ludwig Reiter diff -r 050e9fd21762 roundup/cgi/templating.py --- a/roundup/cgi/templating.py Fri Nov 15 10:41:15 2019 +0100 +++ b/roundup/cgi/templating.py Fri Nov 15 10:43:26 2019 +0100 @@ -3140,6 +3140,20 @@ days = calendar.monthrange(year, month)[1] return date.Interval("+%dd" % days) + def prev_year_interval(display): + # jump to the correct month in the prev year + # try to handle the special 29/02 case. + if display.month == 2 and display.day == 29: + return date.Interval("-366d") + return date.Interval("-1y") + + def next_year_interval(display): + # jump to the correct month in the next year + # try to handle the special 29/02 case. + if display.month == 2 and display.day == 29: + return date.Interval("+364d") + return date.Interval("+1y") + # for navigation try: date_prev_month = display + prev_month_interval(display) @@ -3150,11 +3164,11 @@ except ValueError: date_next_month = None try: - date_prev_year = display + date.Interval("-1y") + date_prev_year = display + prev_year_interval(display) except ValueError: date_prev_year = None try: - date_next_year = display + date.Interval("+1y") + date_next_year = display + next_year_interval(display) except ValueError: date_next_year = None