Message381629
Inside the file calendar.py, there are two functions which are supposed to calculate the previous and next month relative to the actual year and month.
def _prevmonth(year, month):
if month == 1:
return year-1, 12
else:
return year, month-1
def _nextmonth(year, month):
if month == 12:
return year+1, 1
else:
return year, month+1
Because of the concise calculation that is being made by these functions, it would be convenient to use the ternary operator to calculate that. So, the result would be:
def _prevmonth(year, month):
return [year-1, 12] if month == 1 else [year, month-1]
def _nextmonth(year, month):
return [year+1, 1] if month == 12 else [year, month+1] |
|
Date |
User |
Action |
Args |
2020-11-22 19:46:39 | ElianMariano | set | recipients:
+ ElianMariano |
2020-11-22 19:46:39 | ElianMariano | set | messageid: <1606074399.89.0.722883814317.issue42439@roundup.psfhosted.org> |
2020-11-22 19:46:39 | ElianMariano | link | issue42439 messages |
2020-11-22 19:46:39 | ElianMariano | create | |
|