Index: openacs-4/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl,v diff -u -r1.36 -r1.37 --- openacs-4/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl 19 Dec 2002 16:26:19 -0000 1.36 +++ openacs-4/packages/acs-datetime/tcl/acs-calendar-2-procs.tcl 13 Mar 2003 20:22:06 -0000 1.37 @@ -55,45 +55,27 @@ set current_date $date - set date_list [dt_ansi_to_list $current_date] - - set year [dt_trim_leading_zeros [lindex $date_list 0]] - set month [dt_trim_leading_zeros [lindex $date_list 1]] - set day [dt_trim_leading_zeros [lindex $date_list 2]] - - set current_date_julian [dt_ansi_to_julian $year $month $day] - - # 1 = Sun ... 7 = Sat - set current_date_weekday_no [expr [clock format [clock scan $date] -format %w] + 1] - - # What day does the week start on? - # 0 = Sunday, 6 = Saturday - set first_day_of_week [lc_get firstdayofweek] - - set first_day_of_week_julian [expr $current_date_julian - (($current_date_weekday_no + 6 - $first_day_of_week) % 7)] - - set last_week [dt_julian_to_ansi [expr $current_date_julian - 7]] - set last_week_pretty [lc_time_fmt $last_week "%q"] - set next_week [dt_julian_to_ansi [expr $current_date_julian + 7]] - set next_week_pretty [lc_time_fmt $next_week "%q"] - + # Get information for the week + db_1row select_week_info {} + # Initialize the ns_set - if { [empty_string_p $calendar_details] } { + if [empty_string_p $calendar_details] { set calendar_details [ns_set create calendar_details] } - set julian $first_day_of_week_julian - set return_html "\n" + # Loop through the days of the week + set julian $sunday_julian + set return_html "
\n" # Navigation Bar append return_html "
- - +
+
[subst $prev_week_template] - + - [lc_time_fmt [dt_julian_to_ansi $first_day_of_week_julian] "%Q"] - [lc_time_fmt [dt_julian_to_ansi [expr $first_day_of_week_julian + 6]] "%Q"] + [util_AnsiDatetoPrettyDate $sunday_date] - [util_AnsiDatetoPrettyDate $saturday_date] [subst $next_week_template] @@ -106,10 +88,13 @@ " - for { set julian $first_day_of_week_julian } { $julian < [expr $first_day_of_week_julian + 7] } { incr julian } { - set date [dt_julian_to_ansi $julian] - set pretty_date [string totitle [lc_time_fmt $date "%q"]] - set day [string totitle [lc_time_fmt $date "%A"]] + set days_of_week {Sunday Monday Tuesday Wednesday Thursday Friday Saturday} + foreach day $days_of_week { + + set lower_day [string tolower $day] + set julian [set ${lower_day}_julian] + set date [set ${lower_day}_date] + set pretty_date [util_AnsiDatetoPrettyDate $date] set day_html [subst $day_template] if {$date == $today_date} { @@ -149,6 +134,7 @@ append return_html "\n" + incr julian } append return_html "
" @@ -166,8 +152,8 @@ -start_hour {0} -end_hour {23} -show_nav 1 - -prev_nav_template {<} - -next_nav_template {>} + -prev_nav_template {\"back} + -next_nav_template {\"forward} -master_bgcolor "black" -header_bgcolor "black" -header_text_color "white" @@ -196,25 +182,12 @@ set calendar_details [ns_set create calendar_details] } - for { set hour 0 } { $hour < 24 } { incr hour } { - if { ($hour < $start_hour || $hour > $end_hour) && [ns_set find $calendar_details [format "%02d" $hour]] != -1 } { - if { $hour < $start_hour } { - set start_hour $hour - } elseif { $hour > $end_hour } { - set end_hour $hour - } - } - } - # Collect some statistics about the events (for overlap) for {set hour $start_hour} {$hour <= 23} {incr hour} { set n_events($hour) 0 set n_starting_events($hour) 0 } - - # Count number of overlapping events each hour - - # Make a copy of the calendar_details set that we can work on for a minute, discard afterwards. + set calendar_details_2 [ns_set copy $calendar_details] for {set hour $start_hour} {$hour <= $end_hour} {incr hour} { @@ -252,13 +225,12 @@ for {set hour $start_hour} {$hour <= $end_hour} {incr hour} { if {$max_n_events < $n_events($hour)} { set max_n_events $n_events($hour) + ns_log Notice "BMA-DEBUG-CAL: Setting max_n_events to $max_n_events" } } # Select some basic stuff, sets day_of_the_week, yesterday, tomorrow vars db_1row select_day_info {} - - set day_of_the_week [string totitle [lc_time_fmt $current_date "%Q"]] set return_html "" @@ -273,12 +245,12 @@ append return_html "
" - # The items that have no hour (all day events) + # The items that have no hour set hour "" set next_hour "" set start_time "" set odd_row_p 0 - set display_hour "\"No" + set display_hour "\"No" append return_html "" append return_html "" - - # Normal hour-by-hour display + for {set hour $start_hour} {$hour <= $end_hour} {incr hour} { set next_hour [expr $hour + 1] @@ -311,9 +282,34 @@ } else { set index_hour $hour } - - set display_hour [string tolower [string trimleft [lc_time_fmt "0000-00-00 ${hour}:00:00" "%X"] 0]] + # display stuff + if {$hour >= 12} { + set ampm_hour [expr $hour - 12] + set pm 1 + } else { + set ampm_hour $hour + set pm 0 + } + + if {$ampm_hour == 0} { + set ampm_hour 12 + } + + if {$ampm_hour < 10} { + set display_hour "$ampm_hour" + } else { + set display_hour "$ampm_hour" + } + + append display_hour ":00 " + + if {$pm} { + append display_hour "pm" + } else { + append display_hour "am" + } + if { $odd_row_p } { set class "odd" set odd_row_p 0 @@ -412,7 +408,7 @@ } { # Check for zero size if {[ns_set size $calendar_details] == 0} { - return "[_ acs-datetime.No_Items]" + return "No Items" } # The title @@ -422,15 +418,15 @@ } if {[empty_string_p $start_date] && ![empty_string_p $end_date]} { - set title "Items until [lc_time_fmt $end_date "%Q"]" + set title "Items until [util_AnsiDatetoPrettyDate $end_date]" } if {![empty_string_p $start_date] && [empty_string_p $end_date]} { - set title "Items starting [lc_time_fmt $start_date "%Q"]" + set title "Items starting [util_AnsiDatetoPrettyDate $start_date]" } if {![empty_string_p $start_date] && ![empty_string_p $end_date]} { - set title "[_ acs-datetime.Items_from] [lc_time_fmt $start_date "%Q"] [_ acs-datetime.to] [lc_time_fmt $end_date "%Q"]" + set title "Items from [util_AnsiDatetoPrettyDate $start_date] to [util_AnsiDatetoPrettyDate $end_date]" } set return_html "$title

" @@ -445,14 +441,14 @@ # Create the header append return_html "

[subst $hour_template]" @@ -300,8 +272,7 @@ append return_html "
- " + " if {$real_order_by != "item_type"} { - append return_html "" + append return_html "" } - append return_html "\n" + append return_html "\n" # initialize the item_type so we can do intermediate titles set old_item_type "" @@ -478,7 +474,7 @@ # Do we need a title? if {$real_order_by == "item_type" && $item_type != "$old_item_type"} { if {[empty_string_p $item_type]} { - set item_type_for_title "([_ acs-datetime.No_Item_Type])" + set item_type_for_title "(No Item Type)" } else { set item_type_for_title $item_type }
[_ acs-datetime.Day_of_Week][_ acs-datetime.Date][_ acs-datetime.Start_Time][_ acs-datetime.End_Time]
Day of WeekDateStart TimeEnd Time[_ acs-datetime.Type]Type[_ acs-datetime.Title]
Title