Ticket #562 (assigned enhancement)

Opened 2 years ago

Last modified 2 years ago

Allow increments and decrements in year and month views.

Reported by: taa Assigned to: anonymous (accepted)
Priority: normal Component: WikiCalendarMacro
Severity: normal Keywords:
Cc: taa@acm.org Trac Release: 0.9

Description

It would be useful to display two instances of the calendar on the same page; e.g., current month and next month, or current month and previous month, or a combination of both.

Attachments

WikiCalendar_inc_dec_month_and_year.patch (2.2 kB) - added by taa on 08/01/06 17:02:31.
Patch
WikiCalendar.py (7.4 kB) - added by taa on 08/01/06 17:03:19.
New patched version of WikiCalendar? with year and month increment/decrement support

Change History

08/01/06 17:02:00 changed by taa

  • owner changed from mgood to anonymous.
  • status changed from new to assigned.

Proposed solution: allow the year and month parameters to have a sign. If a sign is explicitly specified, then treat the parameters and an increment or decrement according to the sign. If the sign is not used, then the parameter is used as the month or year value.

Support is also added for month > 12 by incrementing the year, and month < 0 by decrementing the year and adding 12 to the month value.

A patch is included below

  • WikiCalendar.py

    old new  
    1010# 
    1111# Author: Matthew Good <trac@matt-good.net> 
    1212# Month/Year navigation by: Jan Finell <finell@cenix-bioscience.com> 
     13# Month/Year increment/decrement parameters by: Tony Abou-Assaleh <taa@acm.org> 
    1314 
    1415import time 
    1516import calendar 
     
    5152    # find out whether use http param, current or macro param year/month 
    5253     
    5354    if http_param_year == "": 
    54         # not clicked on a prev or next button 
    55         if len(args) >= 1 and args[0] <> "*": 
    56             # year given in macro parameters 
    57             year = int(args[0]) 
    58         else: 
    59             # use current year 
    60             year = today.tm_year 
     55        # use current year 
     56        year = today.tm_year 
    6157    else: 
    6258        # year in http params (clicked by user) overrides everything 
    6359        year = int(http_param_year) 
    64      
     60 
     61    # not clicked on a prev or next button 
     62    if len(args) >= 1: 
     63        if args[0][0] == "*": 
     64                pass 
     65        elif args[0][0] in ("-", "+"): 
     66                year += int(args[0]) 
     67        else: 
     68                # year given in macro parameters 
     69                year = int(args[0]) 
     70 
    6571    if http_param_month == "": 
    66         # not clicked on a prev or next button 
    67         if len(args) >= 2 and args[1] <> "*": 
    68             # month given in macro parameters 
    69             month = int(args[1]) 
    70         else: 
    71             # use current month 
    72             month = today.tm_mon 
     72        # use current month 
     73        month = today.tm_mon 
    7374    else: 
    7475        # month in http params (clicked by user) overrides everything 
    7576        month = int(http_param_month) 
    76      
     77 
     78    # not clicked on a prev or next button 
     79    if len(args) >= 2: 
     80        if args[1][1] == "*": 
     81                pass 
     82        elif args[1][1] in ("-", "+"): 
     83                month += int(args[1]) 
     84        else: 
     85                # month given in macro parameters 
     86                month = int(args[1]) 
     87 
     88    # handle month > 12 and month < 1, must shift to month  
     89    # range from [1,12] to [0,11] and back 
     90    year += (month-1) / 12 
     91    month = (month+11) % 12 + 1 
     92 
    7793    showbuttons = 1 
    7894    if len(args) >= 3: 
    7995        showbuttons = bool(args[2]=="True" or args[2]=="true" or args[2]=="no" or args[2]=="0") 

08/01/06 17:02:31 changed by taa

  • attachment WikiCalendar_inc_dec_month_and_year.patch added.

Patch

08/01/06 17:03:19 changed by taa

  • attachment WikiCalendar.py added.

New patched version of WikiCalendar? with year and month increment/decrement support


Add/Change #562 (Allow increments and decrements in year and month views.)




Change Properties
Action