Index: openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs-postgresql.xql,v diff -u -r1.14 -r1.15 --- openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql 5 Sep 2003 08:55:15 -0000 1.14 +++ openacs-4/packages/calendar/tcl/calendar-display-procs-postgresql.xql 22 Sep 2003 09:55:02 -0000 1.15 @@ -7,8 +7,8 @@ select to_char(start_date, 'J') as start_date, - to_char(start_date, 'HH:MIpm') as start_time, - to_char(end_date, 'HH:MIpm') as end_time, + to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date, + to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date, coalesce(e.name, a.name) as name, coalesce(e.description, a.description) as description, coalesce(e.status_summary, a.status_summary) as status_summary, @@ -71,25 +71,13 @@ - - - select to_char(to_date(:current_date, 'yyyy-mm-dd'), 'D') - as day_of_the_week, - to_char(next_day(to_date(:current_date, 'yyyy-mm-dd')- '1 week'::interval, 'Sunday'), 'YYYY-MM-DD') - as sunday_of_the_week, - to_char(next_day(to_date(:current_date, 'yyyy-mm-dd'), 'Saturday'), 'YYYY-MM-DD') - as saturday_of_the_week - from dual - - - select to_char(start_date, 'HH24') as start_hour, - to_char(start_date, 'HH:MIpm') as pretty_start_date, - to_char(end_date, 'HH:MIpm') as pretty_end_date, to_char(start_date, 'HH24:MI') as start_date, to_char(end_date, 'HH24:MI') as end_date, + to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date, + to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date, coalesce(e.name, a.name) as name, coalesce(e.status_summary, a.status_summary) as status_summary, e.event_id as item_id, @@ -108,8 +96,8 @@ and e.activity_id = a.activity_id and start_date between to_date(:current_date,:date_format) and - to_date(:current_date,:date_format) + cast('23 hours 59 minutes 59 seconds' as interval) -and cal_items.cal_item_id= e.event_id + to_date(:current_date,:date_format) + (24 - 1/3600)/24 +and cal_items.cal_item_id= e.event_id and e.event_id in ( select cal_item_id @@ -123,10 +111,8 @@ select to_char(start_date, 'HH24') as start_hour, - to_char(start_date, 'MM/DD/YYYY') as pretty_date, - to_char(start_date, 'Day') as pretty_weekday, - to_char(start_date, 'HH:MIpm') as pretty_start_date, - to_char(end_date, 'HH:MIpm') as pretty_end_date, + to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date, + to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date, coalesce(e.name, a.name) as name, coalesce(e.status_summary, a.status_summary) as status_summary, e.event_id as item_id, @@ -153,6 +139,5 @@ - Index: openacs-4/packages/calendar/tcl/calendar-display-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs.tcl,v diff -u -r1.38 -r1.39 --- openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 5 Sep 2003 08:48:39 -0000 1.38 +++ openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 22 Sep 2003 09:55:02 -0000 1.39 @@ -46,6 +46,14 @@ db_foreach select_monthly_items {} { + # Timezonize + set ansi_start_date [lc_time_utc_to_local $ansi_start_date] + set ansi_end_date [lc_time_utc_to_local $ansi_end_date] + + # Localize + set start_time [lc_time_fmt $ansi_start_date "%X"] + set end_time [lc_time_fmt $ansi_end_date "%X"] + # Calendar name now set in query # set calendar_name [calendar_get_name $calendar_id] @@ -92,7 +100,7 @@ if {[empty_string_p $item_add_template]} { set day_number_template "$day_template" } else { - set day_number_template "$day_template $item_add_template" + set day_number_template "$day_template $item_add_template" } return [dt_widget_month -calendar_details $items -date $date \ @@ -143,14 +151,20 @@ set items [ns_set create] - # This isn't going to be pretty. First we make it work, though. (ben) + # Find the first day of the week in julian + set current_date_weekday_no [expr [clock format [clock scan $date] -format %w] + 1] + set first_day_of_week_julian [expr [dt_ansi_to_julian_single_arg $date] - (($current_date_weekday_no + 6 - [lc_get firstdayofweek]) % 7)] - db_1row select_weekday_info {} - # Loop through the calendars db_foreach select_week_items {} { - ns_log Notice "ONE WEEK ITEM" + # Timezonize + set ansi_start_date [lc_time_utc_to_local $ansi_start_date] + set ansi_end_date [lc_time_utc_to_local $ansi_end_date] + # Localize + set pretty_start_date [lc_time_fmt $ansi_start_date "%X"] + set pretty_end_date [lc_time_fmt $ansi_end_date "%X"] + # now selected from the query # set calendar_name [calendar_get_name $calendar_id] @@ -204,8 +218,8 @@ {-calendar_id_list ""} {-hour_template {$hour}} {-item_template {$item}} - {-prev_nav_template {}} - {-next_nav_template {}} + {-prev_nav_template {<}} + {-next_nav_template {>}} {-start_hour 0} {-end_hour 23} {-url_stub_callback ""} @@ -237,8 +251,27 @@ set items [ns_set create] + set timezone [lang::conn::timezone] + # Loop through the calendars db_foreach select_day_items {} { + # Timezonize + + #error "timezone = $timezone ; start_interval = $start_interval ; end_interval = $end_interval" + #error "timezone = $timezone ; ansi_start_original $ansi_start_date ; name = $name" + + set ansi_start_date [lc_time_utc_to_local $ansi_start_date] + set ansi_end_date [lc_time_utc_to_local $ansi_end_date] + + # other date/time formats + set start_hour [lc_time_fmt $ansi_start_date "%H"] + set start_date [lc_time_fmt $ansi_start_date "%H:%M"] + set end_date [lc_time_fmt $ansi_end_date "%H:%M"] + + # Localize + set pretty_start_date [lc_time_fmt $ansi_start_date "%X"] + set pretty_end_date [lc_time_fmt $ansi_end_date "%X"] + # Not needed anymore # set calendar_name [calendar_get_name $calendar_id] @@ -346,6 +379,10 @@ } db_foreach select_list_items {} { + # Timezonize + set ansi_start_date [lc_time_utc_to_local $ansi_start_date] + set ansi_end_date [lc_time_utc_to_local $ansi_end_date] + ns_log Notice "BMA-CHECK: test $name" set item "$name" set item [subst $item_template] @@ -354,6 +391,12 @@ append item " ($calendar_name)" } + # Localize + set pretty_date [lc_time_fmt $ansi_start_date "%x"] + set pretty_weekday [lc_time_fmt $ansi_start_date "%A"] + set pretty_start_date [lc_time_fmt $ansi_start_date "%X"] + set pretty_end_date [lc_time_fmt $ansi_end_date "%X"] + ns_set put $items $start_hour [list $pretty_date $pretty_start_date $pretty_end_date $pretty_weekday $item_type $item] } @@ -370,83 +413,4 @@ } -# ad_proc -public list_display { -# {-date ""} -# {-calendar_id_list ""} -# {-item_template {$item}} -# {-url_stub_callback ""} -# {-show_calendar_name_p 1} -# } { -# Creates a list widget -# } { -# if {[empty_string_p $date]} { -# set date [dt_sysdate] -# } - -# set date_format "YYYY-MM-DD HH24:MI" -# set current_date $date - -# # If we were given no calendars, we assume we display the -# # private calendar. It makes no sense for this to be called with -# # no data whatsoever. -# if {[empty_string_p $calendar_id_list]} { -# set calendar_id_list [list [calendar_have_private_p -return_id 1 [ad_get_user_id]]] -# } - -# set items [ns_set create] - -# # Loop through the calendars -# foreach calendar_id $calendar_id_list { -# set calendar_name [calendar_get_name $calendar_id] - -# # In case we need to dispatch to a different URL (ben) -# if {![empty_string_p $url_stub_callback]} { -# set url_stub [$url_stub_callback $calendar_id] -# } - -# db_foreach select_day_items {} { -# # ns_log Notice "bma: one item" -# set item "$pretty_start_date - $pretty_end_date: $name" - -# if {$show_calendar_name_p} { -# append item " ($calendar_name)" -# } - -# set item [subst $item_template] - -# ns_set put $items $start_hour $item -# } - -# } - -# set return_html "Items for [util_AnsiDatetoPrettyDate $date]:\n" - -# for {set i 0} {$i <= 23} {incr i} { -# if {$i < 10} { -# set index_hour "0$i" -# } else { -# set index_hour $i -# } - -# while {1} { -# set index [ns_set find $items $index_hour] -# if {$index == -1} { -# break -# } - -# # ns_log Notice "bma: one item found !!" - -# append return_html " [ns_set value $items $index]\n" -# ns_set delete $items $index -# } -# append return_html "" -# } - -# append return_html "" - -# return $return_html -# } - - - }
" -# } - -# append return_html "