Index: openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl,v diff -u -N -r1.11 -r1.11.2.1 --- openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 18 Sep 2002 21:03:59 -0000 1.11 +++ openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 13 Mar 2003 02:18:58 -0000 1.11.2.1 @@ -469,20 +469,54 @@ set now [clock scan $date] # Compute formatted strings for curr, prev, and next - set prev_year [clock format [clock scan "1 year ago" -base $now] -format "%Y-%m-%d"] - set next_year [clock format [clock scan "1 year" -base $now] -format "%Y-%m-%d"] + + # Check that links to prev/next year don't lead to illegal dates that would bomb + if {[catch {set prev_year [clock format [clock scan "1 year ago" -base $now] -format "%Y-%m-%d"]} err]} { + set prev_year_legal_p 0 + } else { + if {[catch {clock scan $prev_year}]} { + set prev_year_legal_p 0 + } else { + set prev_year_legal_p 1 + } + } + + if {[catch {set next_year [clock format [clock scan "1 year" -base $now] -format "%Y-%m-%d"]} err]} { + set next_year_legal_p 0 + } else { + if {[catch {clock scan $next_year}]} { + set next_year_legal_p 0 + } else { + set next_year_legal_p 1 + } + } + set curr_year [clock format $now -format "%Y"] append result " -
+
" + + # Serve arrow link to prev year if it leads to legal date + if {$prev_year_legal_p != 0} { + append result " - - $curr_year + " + } + + append result " + $curr_year" + + # Serve arrow to next year if it leads to a legal date + if {$next_year_legal_p != 0} { + append result " - + " + } + + append result "
@@ -501,21 +535,54 @@ } { set now [clock scan $date] set curr_month [clock format $now -format "%B"] - set prev_month [clock format [clock scan "1 month ago" -base $now] -format "%Y-%m-%d"] - set next_month [clock format [clock scan "1 month" -base $now] -format "%Y-%m-%d"] + # Check that the arrows to prev/next months don't go to illegal dates and bomb + if {[catch {set prev_month [clock format [clock scan "1 month ago" -base $now] -format "%Y-%m-%d"]} err ]} { + set prev_month_legal_p 0 + } else { + if {[catch {clock scan $prev_month}]} { + set prev_month_legal_p 0 + } else { + set prev_month_legal_p 1 + } + } + + if {[catch {set next_month [clock format [clock scan "1 month" -base $now] -format "%Y-%m-%d"]} err]} { + set next_month_legal_p 0 + } else { + if {[catch {clock scan $next_month}]} { + set next_month_legal_p 0 + } else { + set next_month_legal_p 1 + } + } + append results " - \n" - + return $results }
+
" + + # Output link to previous month only if it's legal + if {$prev_month_legal_p != 0} { + append results " - - $curr_month + " + } + + append results " + $curr_month" + + # Output link to next month only if it's a legal month + if {$next_month_legal_p != 0} { + append results " - + " + } + + append results "