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.14 -r1.15 --- openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 12 Nov 2002 08:54:34 -0000 1.14 +++ openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 18 Nov 2002 18:01:12 -0000 1.15 @@ -43,10 +43,9 @@ HTML formatting) that represents the details. } { if {[string equal $days_of_week "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"]} { - set days_of_week [list [_ acs-datetime.Sunday] [_ acs-datetime.Monday] [_ acs-datetime.Tuesday] [_ acs-datetime.Wednesday] [_ acs-datetime.Thursday] [_ acs-datetime.Friday] [_ acs-datetime.Saturday]] + set days_of_week [nsv_get locale "[lang::conn::locale],day"] } - dt_get_info $date set today_date [dt_sysdate] @@ -58,7 +57,7 @@ set day_of_week $first_day_of_month set julian_date $first_julian_date - set month_heading [format "%s %s" $month $year] + set month_heading [string totitle [lc_time_fmt $date "%B %Y"]] set next_month_url "" set prev_month_url "" @@ -75,7 +74,7 @@ # We offer an option to put the links to next and previous months # in the title bar - if { $prev_next_links_in_title == 0 } { + if { !$prev_next_links_in_title } { set title " $month_heading @@ -102,7 +101,12 @@ $title \n" - foreach day_of_week $days_of_week { + set days_of_week {} + foreach day [nsv_get locale [lang::conn::locale],day] { + lappend days_of_week [string totitle $day] + } + for { set i 0 } { $i < 7 } { incr i } { + set day_of_week [lindex $days_of_week [expr ($i + $first_day_of_week) % 7 ]] append output " @@ -433,6 +437,7 @@ } ad_proc -private dt_navbar_view { + {-link_current_view:boolean} view base_url date @@ -457,16 +462,18 @@ Week {set text "[_ acs-datetime.Week]"} Month {set text "[_ acs-datetime.Month]"} } + + set url "${base_url}view=$viewname&date=$date" - if { $viewname == $view } { + if { !$link_current_view_p && [string equal $viewname $view] } { # current view append result " $text " } else { append result " - + $text " @@ -529,20 +536,23 @@ Returns the monthly navbar } { set now [clock scan $date] - set curr_month_en_US [clock format $now -format "%B"] - set curr_month_localized [_ acs-datetime.${curr_month_en_US}] + + + set curr_month_localized [string totitle [lc_time_fmt [clock_to_ansi $now] "%B %Y"]] + 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"] + set prev_month_localized [string totitle [lc_time_fmt $prev_month "%B %Y"]] + set next_month_localized [string totitle [lc_time_fmt $next_month "%B %Y"]] + append results " \n" @@ -551,7 +561,8 @@ ad_proc dt_widget_calendar_navigation { - {} + {-today_bgcolor "#e9e99c"} + -link_current_view:boolean {base_url ""} {view "week"} {date ""} @@ -604,20 +615,25 @@ set output "
- - + $curr_month_localized - - +
- [dt_navbar_view $view $base_url $date] + [dt_navbar_view -link_current_view=$link_current_view_p $view $base_url $date] [dt_navbar_year $view $base_url $date]\n" if [string equal $view month] { # month view + append output "
" + + set months_list [list] + foreach month_name [nsv_get locale [lang::conn::locale],mon] { + lappend months_list [string totitle $month_name] + } - set months_list [dt_month_names] set now [clock scan $date] set curr_month [expr [dt_trim_leading_zeros [clock format $now -format "%m"]]-1] @@ -681,6 +697,8 @@ append output "" } else { + + # day or week view append output " [dt_navbar_month $view $base_url $date] @@ -693,18 +711,23 @@ " - set days_of_week "[_ acs-datetime.S_M_T_W_T_F_S]" + set first_day_of_week [nsv_get locale [lang::conn::locale],firstdayofweek] - - foreach day_of_week $days_of_week { - append output "\n" + set days_of_week {} + foreach day [nsv_get locale [lang::conn::locale],abday] { + lappend days_of_week [string toupper [string range $day 0 0]] + } + for { set i 0 } { $i < 7 } { incr i } { + append output "\n" } append output "" set day_of_week 1 set julian_date $first_julian_date set day_number $first_day + set julian_date_todays_date [dt_ansi_to_julian_single_arg [dt_sysdate]] + while {1} { if {$julian_date < $first_julian_date_of_month} { @@ -732,20 +755,26 @@ append output "\n" } + if { $julian_date == $julian_date_todays_date } { + set bgcolor " bgcolor=\"${today_bgcolor}\"" + } else { + set bgcolor {} + } + if {$before_month_p || $after_month_p} { append output " - " } elseif {$julian_date == $julian_date_today} { append output " - " } else { append output " - " @@ -788,10 +817,10 @@ } append output " - [_ acs-datetime.is] [dt_ansi_to_pretty] + [_ acs-datetime.is] [lc_time_fmt [dt_sysdate] "%q"]
$day_of_week[lindex $days_of_week [expr ($i + $first_day_of_week) % 7 ]]

+ $day_number + $day_number + $day_number

-
[_ acs-datetime.Date_as] YYYYMMDD +
[_ acs-datetime.Date_as_YYYYMMDD] " @@ -821,7 +850,7 @@ Returns the following (example for the_date = 2000-12-08): julian_date_today 2451887 - month December + month December (localized) year 2000 first_julian_date 2451875 first_julian_date_of_month 2451880 @@ -835,8 +864,8 @@ prev_month 2000-11-08 beginning_of_year 2000-01-01 days_in_last_month 30 - next_month_name January - prev_month_name November + next_month_name January (localized) + prev_month_name November (localized) Input: @@ -862,7 +891,7 @@ ns_set put $dt_info_set julian_date_today \ [dt_ansi_to_julian $year $month $day] ns_set put $dt_info_set month \ - [clock format [clock scan $the_date] -format %B] + [lc_time_fmt $the_date "%B"] ns_set put $dt_info_set year \ [clock format [clock scan $the_date] -format %Y] ns_set put $dt_info_set first_julian_date_of_month \ @@ -885,19 +914,23 @@ [dt_next_month_name $year $month] ns_set put $dt_info_set prev_month_name \ [dt_prev_month_name $year $month] + ns_set put $dt_info_set first_day_of_week \ + [nsv_get locale [lang::conn::locale],firstdayofweek] - # We need the variables from the ns_set + # We need the variables from the ns_set here ad_ns_set_to_tcl_vars $dt_info_set ns_set put $dt_info_set first_julian_date \ - [expr $first_julian_date_of_month + 1 - $first_day_of_month] + [expr $first_julian_date_of_month - (($first_day_of_month + 6 - $first_day_of_week) % 7)] + ns_set put $dt_info_set first_day \ - [expr $days_in_last_month + 2 - $first_day_of_month] + [expr $days_in_last_month - (($first_day_of_month + 6 - $first_day_of_week) %7) + 1] + ns_set put $dt_info_set last_julian_date_in_month \ [expr $first_julian_date_of_month + $num_days_in_month - 1] set days_in_next_month \ - [expr (7-(($num_days_in_month + $first_day_of_month - 1) % 7)) % 7] + [expr (7-(($num_days_in_month + $first_day_of_month - $first_day_of_week - 1) % 7)) % 7] ns_set put $dt_info_set last_julian_date \ [expr $first_julian_date_of_month + $num_days_in_month - 1 + $days_in_next_month]