Index: openacs-4/packages/calendar/www/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.tcl,v diff -u -r1.7.2.1 -r1.7.2.2 --- openacs-4/packages/calendar/www/view.tcl 6 Mar 2003 21:34:21 -0000 1.7.2.1 +++ openacs-4/packages/calendar/www/view.tcl 13 Mar 2003 02:19:35 -0000 1.7.2.2 @@ -15,7 +15,7 @@ } -validate { valid_date -requires { date } { if {![string equal $date ""]} { - if {[catch {set date [clock format [clock scan $date] -format "%Y%m%d"]} err]} { + if {[catch {set date [clock format [clock scan $date] -format "%Y-%m-%d"]} err]} { ad_complain "Your input was not valid. It has to be in the form YYYYMMDD." } } @@ -37,9 +37,32 @@ # Depending on the view, make a different widget if {$view == "day"} { + + # Check that the previous and next days are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set yest [clock format [clock scan "1 day ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $yest}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set tomor [clock format [clock scan "1 day" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $tomor}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_day_display \ - -prev_nav_template "<" \ - -next_nav_template ">" \ + -prev_nav_template $previous_link \ + -next_nav_template $next_link \ -item_template $item_template \ -hour_template $hour_template \ -date $date -start_hour 7 -end_hour 22 \ @@ -48,25 +71,71 @@ } if {$view == "week"} { + + # Check that the previous and next weeks are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set prev_w [clock format [clock scan "1 week ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $prev_w}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set next_w [clock format [clock scan "1 week" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_w}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_week_display \ -item_template $item_template \ -day_template "\$day - \$pretty_date     (Add Item)" \ -date $date \ -calendar_id_list $calendar_list \ - -prev_week_template "<" \ - -next_week_template ">" - ] + -prev_week_template $previous_link \ + -next_week_template $next_link] + } if {$view == "month"} { + + # Check that the previous and next months are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set prev_m [clock format [clock scan "1 month ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $prev_m}]} { + set previous_link "" + } else { + set previous_link "<" + } + } + + if {[catch {set next_m [clock format [clock scan "1 month" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_m}]} { + set next_link "" + } else { + set next_link ">" + } + } + set cal_stuff [calendar::one_month_display \ -item_template "$item_template" \ -day_template "\$day_number" \ -date $date \ -item_add_template "$item_add_template" \ -calendar_id_list $calendar_list \ - -prev_month_template "<" \ - -next_month_template ">"] + -prev_month_template $previous_link \ + -next_month_template $next_link] } if {$view == "list"} {