Index: openacs-4/packages/acs-datetime/acs-datetime.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/acs-datetime.info,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-datetime/acs-datetime.info 24 Oct 2002 07:46:56 -0000 1.8 +++ openacs-4/packages/acs-datetime/acs-datetime.info 22 Nov 2002 13:13:42 -0000 1.9 @@ -25,12 +25,15 @@ + + + Index: openacs-4/packages/acs-datetime/catalog/acs-datetime.da_DK.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/catalog/acs-datetime.da_DK.ISO-8859-1.xml,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-datetime/catalog/acs-datetime.da_DK.ISO-8859-1.xml 7 Nov 2002 08:41:32 -0000 1.1 +++ openacs-4/packages/acs-datetime/catalog/acs-datetime.da_DK.ISO-8859-1.xml 22 Nov 2002 13:13:44 -0000 1.2 @@ -3,40 +3,20 @@ I dag - S M T O T F L Type til Liste er Starttidspunkt - S�ndag Sluttidspunkt Emner fra Dag - Tirsdag - Mandag Datoen skrives som Titel Uge Ingen emnetype - Onsdag - Torsdag Ugedag - L�rdag M�ned Dato Ingen emner - Fredag - Januar - Februar - Marts - April - Maj - Juni - Juli - August - September - Oktober - November - December Index: openacs-4/packages/acs-datetime/catalog/acs-datetime.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/catalog/acs-datetime.en_US.ISO-8859-1.xml,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-datetime/catalog/acs-datetime.en_US.ISO-8859-1.xml 7 Nov 2002 08:41:32 -0000 1.1 +++ openacs-4/packages/acs-datetime/catalog/acs-datetime.en_US.ISO-8859-1.xml 22 Nov 2002 13:13:44 -0000 1.2 @@ -3,40 +3,20 @@ Today - S M T W T F S Type to is List Start Time - Sunday End Time Items from Day - Tuesday - Monday Date as Title Week No Item Type - Wednesday - Thursday Day of Week - Saturday Month Date No Items - Friday - January - February - March - April - May - June - July - August - September - October - November - December 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 -r1.15 -r1.16 --- openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 18 Nov 2002 18:01:12 -0000 1.15 +++ openacs-4/packages/acs-datetime/tcl/acs-calendar-procs.tcl 22 Nov 2002 13:13:44 -0000 1.16 @@ -13,7 +13,8 @@ { -calendar_details "" -date "" - -days_of_week "Sunday Monday Tuesday Wednesday Thursday Friday Saturday" + -days_of_week "deprecated" + -weekday_format "long" -large_calendar_p 1 -master_bgcolor "black" -header_bgcolor "black" @@ -42,10 +43,6 @@ Julian date of the day, and the value is a string (possibly with HTML formatting) that represents the details. } { - if {[string equal $days_of_week "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"]} { - set days_of_week [nsv_get locale "[lang::conn::locale],day"] - } - dt_get_info $date set today_date [dt_sysdate] @@ -101,16 +98,11 @@ $title \n" - 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 ]] + foreach weekday [dt_get_days_of_week -weekday_format $weekday_format] { append output " - $day_of_week + $weekday \n" } @@ -216,7 +208,8 @@ { -calendar_details "" -date "" - -days_of_week "S M T W T F S" + -days_of_week "deprecated" + -weekday_format "1" -large_calendar_p 0 -master_bgcolor "black" -header_bgcolor "black" @@ -234,15 +227,14 @@ } } { Returns a small calendar for a specific month. Defaults to this month. -} { - if {[string equal $days_of_week "S M T W T F S"]} { - set days_of_week "[_ acs-datetime.S_M_T_W_T_F_S]" - } + @param weekday_format This can be either '1' for 1-character abbreviations, 'ab' for + standard 3-letter abbreviations, and 'long' for the full names of weekdays. +} { return [dt_widget_month \ -calendar_details $calendar_details \ -date $date \ - -days_of_week $days_of_week \ + -weekday_format $weekday_format \ -large_calendar_p $large_calendar_p \ -master_bgcolor $master_bgcolor \ -header_bgcolor $header_bgcolor \ @@ -263,7 +255,8 @@ { -calendar_details "" -date "" - -days_of_week "S M T W T F S" + -days_of_week "deprecated" + -weekday_format "1" -large_calendar_p 0 -master_bgcolor "black" -header_bgcolor "black" @@ -282,28 +275,27 @@ } { Returns a calendar for a specific month, with details supplied by Julian date. Defaults to this month. + + @param weekday_format This can be either '1' for 1-character abbreviations, 'ab' for + standard 3-letter abbreviations, and 'long' for the full names of weekdays. } { - if {[string equal $days_of_week "S M T W T F S"]} { - set days_of_week "[_ acs-datetime.S_M_T_W_T_F_S]" - } + set output {} - set output "" - dt_get_info $date append output " + [dt_widget_month_small -calendar_details $calendar_details -date $prev_month -weekday_format $weekday_format -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ]
- [dt_widget_month_small -calendar_details $calendar_details -date $prev_month -days_of_week $days_of_week -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] - [dt_widget_month_small -calendar_details $calendar_details -date $date -days_of_week $days_of_week -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] + [dt_widget_month_small -calendar_details $calendar_details -date $date -weekday_format $weekday_format -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] - [dt_widget_month_small -calendar_details $calendar_details -date $next_month -days_of_week $days_of_week -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] + [dt_widget_month_small -calendar_details $calendar_details -date $next_month -weekday_format $weekday_format -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ]
\n" @@ -315,7 +307,8 @@ { -calendar_details "" -date "" - -days_of_week "S M T W T F S" + -days_of_week "deprecated" + -weekday_format "1" -large_calendar_p 0 -master_bgcolor "black" -header_bgcolor "black" @@ -335,11 +328,10 @@ Returns a year of small calendars given the starting month as a date. Defaults to this month. Data in calendar_details will be ignored. -} { - if {[string equal $days_of_week "S M T W T F S"]} { - set days_of_week "[_ acs-datetime.S_M_T_W_T_F_S]" - } + @param weekday_format This can be either '1' for 1-character abbreviations, 'ab' for + standard 3-letter abbreviations, and 'long' for the full names of weekdays. +} { if { $width < 1 || $width > 12 } { return "Width must be between 1 and 12" } @@ -352,7 +344,7 @@ append output " - [dt_widget_month_small -calendar_details $calendar_details -date $date -days_of_week $days_of_week -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] + [dt_widget_month_small -calendar_details $calendar_details -date $date -weekday_format $weekday_format -large_calendar_p $large_calendar_p -master_bgcolor $master_bgcolor -header_bgcolor $header_bgcolor -header_text_color $header_text_color -header_text_size $header_text_size -day_number_template $day_number_template -day_header_size $day_header_size -day_header_bgcolor $day_header_bgcolor -calendar_width $calendar_width -day_bgcolor $day_bgcolor -day_text_color $day_text_color -empty_bgcolor $empty_bgcolor -next_month_template $next_month_template -prev_month_template $prev_month_template ] \n" incr current_width @@ -372,7 +364,8 @@ { -calendar_details "" -date "" - -days_of_week "S M T W T F S" + -days_of_week "deprecated" + -weekday_format "1" -large_calendar_p 0 -master_bgcolor "black" -header_bgcolor "black" @@ -392,17 +385,16 @@ } { Returns a calendar year of small calendars for the year of the passed in date. Defaults to this year. -} { - if {[string equal $days_of_week "S M T W T F S"]} { - set days_of_week "[_ acs-datetime.S_M_T_W_T_F_S]" - } + @param weekday_format This can be either '1' for 1-character abbreviations, 'ab' for + standard 3-letter abbreviations, and 'long' for the full names of weekdays. +} { dt_get_info $date return [dt_widget_year \ -calendar_details $calendar_details \ -date $beginning_of_year \ - -days_of_week $days_of_week \ + -weekday_format $weekday_format \ -large_calendar_p $large_calendar_p \ -master_bgcolor $master_bgcolor \ -header_bgcolor $header_bgcolor \ @@ -559,9 +551,51 @@ return $results } +ad_proc dt_get_days_of_week { + {-weekday_format "1"} +} { + Get the localized names of the days of week, starting with the + correct day according to the locale (e.g., Sunday in the US, Monday in + Europe). + + @param weekday_format: '1' for one-character abbreviations, 'ab' for 3-character abbreviations, + and 'long' for full weekday names. + @return A list of localized weekday names starting with the first day of week according to the connection's locale. +} { + set first_day_of_week [lc_get firstdayofweek] + + # Let's first get the localized weekday names from the localization-procs + switch -exact $weekday_format { + 1 { + set localized_weekdays [list] + foreach day [lc_get abday] { + lappend localized_weekdays [string range $day 0 0] + } + } + ab { + set localized_weekdays [lc_get abday] + } + long { + set localized_weekdays [lc_get day] + } + default { + error "dt_get_days_of_week only knows about formats 1, ab, and long. We were given the format '$weekday_format'." + } + } + + # And now let's put them in the right order according to what day the week starts + set days_of_week [list] + for { set i 0 } { $i < 7 } { incr i } { + lappend days_of_week [string totitle [lindex $localized_weekdays [expr ($i + $first_day_of_week) % 7 ]]] + } + return $days_of_week +} + + ad_proc dt_widget_calendar_navigation { {-today_bgcolor "#e9e99c"} + {-weekday_format "1"} -link_current_view:boolean {base_url ""} {view "week"} @@ -580,7 +614,6 @@ The date must be formatted YYYY-MM-DD. } { - # valid views are "list" "day" "week" "month" "year" if {![exists_and_not_null base_url]} { @@ -711,14 +744,8 @@ " - set first_day_of_week [nsv_get locale [lang::conn::locale],firstdayofweek] - - 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 "[lindex $days_of_week [expr ($i + $first_day_of_week) % 7 ]]\n" + foreach weekday [dt_get_days_of_week -weekday_format 1] { + append output "$weekday\n" } append output "
" Index: openacs-4/packages/acs-datetime/tcl/test/acs-calendar-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-datetime/tcl/test/Attic/acs-calendar-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-datetime/tcl/test/acs-calendar-procs.tcl 22 Nov 2002 13:13:45 -0000 1.1 @@ -0,0 +1,14 @@ +aa_register_case dt_get_days_of_week { +} { + set old_locale [ad_conn locale] + + ad_conn -set locale en_US + aa_true "1-letter weekdays in en_US: [dt_get_days_of_week]" [string equal [dt_get_days_of_week] "S M T W T F S"] + aa_true "3-letter weekdays in en_US: [dt_get_days_of_week -weekday_format ab]" [string equal [dt_get_days_of_week -weekday_format ab] "Sun Mon Tue Wed Thu Fri Sat"] + aa_true "Long weekdays in en_US: [dt_get_days_of_week -weekday_format long]" [string equal [dt_get_days_of_week -weekday_format long] "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"] + + ad_conn -set locale da_DK + aa_true "1-letter weekdays in da_DK: [dt_get_days_of_week]" [string equal [dt_get_days_of_week] "M T O T F L S"] + + ad_conn -set locale $old_locale +}