Index: openacs-4/packages/acs-lang/tcl/localization-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/localization-procs.tcl,v diff -u -N -r1.23.8.2 -r1.23.8.3 --- openacs-4/packages/acs-lang/tcl/localization-procs.tcl 3 Sep 2013 08:15:07 -0000 1.23.8.2 +++ openacs-4/packages/acs-lang/tcl/localization-procs.tcl 24 Sep 2013 18:56:33 -0000 1.23.8.3 @@ -199,132 +199,9 @@ } regsub {\.} $out $dec out - return [lc_sepfmt $out $grouping $sep] } -ad_proc -public lc_monetary_currency { - { -label_p 0 } - { -style local } - num currency locale -} { - Formats a monetary amount, based on information held on given currency (ISO code), e.g. GBP, USD. - - @param label_p Set switch to a true value if you want to specify the label used for the currency. - @param style Set to int to display the ISO code as the currency label. Otherwise displays - an HTML entity for the currency. The label parameter must be true for this - flag to take effect. - @param num Number to format as a monetary amount. - @param currency ISO currency code. - @param locale Locale used for formatting the number. - @return Formatted monetary amount -} { - - set row_returned [db_0or1row lc_currency_select {}] - - if { !$row_returned } { - ns_log Warning "lc_monetary_currency: Unsupported monetary currency, defaulting digits to 2" - set fractional_digits 2 - set html_entity "" - } - - if { $label_p } { - if {$style eq "int" } { - set use_as_label $currency - } else { - set use_as_label $html_entity - } - } else { - set use_as_label "" - } - - return [lc_monetary -- $num $locale $fractional_digits $use_as_label] -} - - -ad_proc -private lc_monetary { - { -label_p 0 } - { -style local } - num - locale - {forced_frac_digits ""} - {forced_currency_symbol ""} -} { - Formats a monetary amount. - - @param label Specify this switch if you want to specify the label used for the currency. - @param style Set to int to display the ISO code as the currency label. Otherwise displays - an HTML entity for the currency. The label parameter must be specified for this - flag to take effect. - @param num Number to format as a monetary amount. If this number could be negative - you should put "--" in your call before it. - @param currency ISO currency code. - @param locale Locale used for formatting the number. - @return Formatted monetary amount -} { - - if {$forced_frac_digits ne "" && [string is integer $forced_frac_digits]} { - set dig $forced_frac_digits - } else { - # look up the digits - if {$style eq "int" } { - set dig [lc_get -locale $locale "int_frac_digits"] - } else { - set dig [lc_get -locale $locale "frac_digits"] - } - } - - # figure out if negative - if {$num < 0} { - set num [expr {abs($num)}] - set neg 1 - } else { - set neg 0 - } - - # generate formatted number - set out [format "%.${dig}f" $num] - - # look up the label if needed - if {$forced_currency_symbol eq ""} { - if {$label_p} { - if {$style eq "int" } { - set sym [lc_get -locale $locale "int_curr_symbol"] - } else { - set sym [lc_get -locale $locale "currency_symbol"] - } - } else { - set sym {} - } - } else { - set sym $forced_currency_symbol - } - - # signorama - if {$neg} { - set cs_precedes [lc_get -locale $locale "n_cs_precedes"] - set sep_by_space [lc_get -locale $locale "n_sep_by_space"] - set sign_pos [lc_get -locale $locale "n_sign_posn"] - set sign [lc_get -locale $locale "negative_sign"] - } else { - set cs_precedes [lc_get -locale $locale "p_cs_precedes"] - set sep_by_space [lc_get -locale $locale "p_sep_by_space"] - set sign_pos [lc_get -locale $locale "p_sign_posn"] - set sign [lc_get -locale $locale "positive_sign"] - } - - # decimal seperator - set dec [lc_get -locale $locale "mon_decimal_point"] - regsub {\.} $out $dec out - - # commify - set sep [lc_get -locale $locale "mon_thousands_sep"] - set grouping [lc_get -locale $locale "mon_grouping"] - set num [lc_sepfmt $out $grouping $sep] - - return [subst [nsv_get locale "money:$cs_precedes$sign_pos$sep_by_space"]] -} - ad_proc -public clock_to_ansi { seconds } { @@ -658,9 +535,9 @@ ad_proc -private lc_time_drop_meridian { hours } { Converts HH24 to HH12. } { - if {$hours>12} { + if {$hours > 12} { incr hours -12 - } elseif {$hours==0} { + } elseif {$hours == 0} { set hours 12 } return $hours Index: openacs-4/packages/acs-lang/tcl/localization-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/localization-procs.xql,v diff -u -N --- openacs-4/packages/acs-lang/tcl/localization-procs.xql 17 May 2003 09:48:30 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,23 +0,0 @@ - - - - - - - select fractional_digits, - html_entity - from currency_codes - where iso = :currency - - - - - - - - select distinct tz, gmt_offset from timezones order by tz - - - - - Index: openacs-4/packages/acs-lang/www/admin/test/format-test.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/test/format-test.tcl,v diff -u -N --- openacs-4/packages/acs-lang/www/admin/test/format-test.tcl 7 Oct 2002 14:32:49 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,30 +0,0 @@ -#/packages/lang/www/test.tcl -ad_page_contract { - - Tests procedures in the lang package - - @author John Lowry (lowry@ardigita.com) - @creation-date 29 September 2000 - @cvs-id $Id: format-test.tcl,v 1.1 2002/10/07 14:32:49 lars Exp $ -} { } - -set title "Test acs-lang package formatting routines" -set header [ad_header $title] -# set navbar [ad_context_bar "Test"] -set footer [ad_footer] - -db_1row lang_system_time_select "SELECT to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') AS system_time FROM dual" - -# Test 5 checks the localization routines -set us_number [lc_numeric 123456.789 {} en_US] -set fr_number [lc_numeric 123456.789 {} fr_FR] -set us_parse [lc_parse_number 123,456.789 en_US] -set fr_parse [lc_parse_number "123 456,789" fr_FR] -set us_currency [lc_monetary_currency -label_p 1 -style local 123.4 USD en_US] -set fr_currency [lc_monetary_currency -label_p 1 -style local 123.4 USD fr_FR] -set us_label [lc_monetary_currency -label_p 1 -style local 1234 FRF en_US] -set fr_label [lc_monetary_currency -label_p 1 -style local 1234 FRF fr_FR] -set us_time [lc_time_fmt $system_time "%c" en_US] -set fr_time [lc_time_fmt $system_time "%c" fr_FR] - -ad_return_template \ No newline at end of file Index: openacs-4/packages/acs-lang/www/admin/test/test.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/test/test.tcl,v diff -u -N -r1.3 -r1.3.10.1 --- openacs-4/packages/acs-lang/www/admin/test/test.tcl 10 Jan 2007 21:22:04 -0000 1.3 +++ openacs-4/packages/acs-lang/www/admin/test/test.tcl 24 Sep 2013 18:56:33 -0000 1.3.10.1 @@ -63,16 +63,4 @@ set tokyo_utc_time [lc_time_local_to_utc $paris_time "Asia/Tokyo"] -# Test 5 checks the localization routines -set us_number [lc_numeric 123456.789 {} en_US] -set fr_number [lc_numeric 123456.789 {} fr_FR] -set us_parse [lc_parse_number 123,456.789 en_US] -set fr_parse [lc_parse_number "123 456,789" fr_FR] -set us_currency [lc_monetary_currency -label_p 1 -style local 123.4 USD en_US] -set fr_currency [lc_monetary_currency -label_p 1 -style local 123.4 USD fr_FR] -set us_label [lc_monetary_currency -label_p 1 -style local 1234 FRF en_US] -set fr_label [lc_monetary_currency -label_p 1 -style local 1234 FRF fr_FR] -set us_time [lc_time_fmt $system_time "%c" en_US] -set fr_time [lc_time_fmt $system_time "%c" fr_FR] - ad_return_template \ No newline at end of file