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 -r1.24.2.3 -r1.24.2.4 --- openacs-4/packages/acs-lang/tcl/localization-procs.tcl 9 Feb 2017 17:18:01 -0000 1.24.2.3 +++ openacs-4/packages/acs-lang/tcl/localization-procs.tcl 13 Feb 2017 13:57:26 -0000 1.24.2.4 @@ -89,14 +89,8 @@ regsub -all "$dec" $number "." number } - - # Strip leading zeros - regexp -- "0*(\[0-9\.\]+)" $number match number + set number [lc_trim_leading_zeros $number] - # if number is real and mod(number)<1, then we have pulled off - # the leading zero; i.e. 0.231 -> .231 -- this is still fine - # for Tcl though... - # Last pathological case if {"." eq $number } { set number 0 @@ -329,7 +323,7 @@ error "Invalid date: $datetime" } } - set lc_time_year [dt_trim_leading_zeros $lc_time_year] + set lc_time_year [lc_trim_leading_zeros $lc_time_year] set a [expr {(14 - $lc_time_month) / 12}] set y [expr {$lc_time_year - $a}] @@ -341,6 +335,27 @@ return [subst [util_memoize [list lc_time_fmt_compile $fmt $locale]]] } +ad_proc -private lc_trim_leading_zeros { + string +} { + Returns a string w/ leading zeros trimmed. + Used to get around Tcl interpreter problems w/ thinking leading + zeros are octal. + + If string is real and mod(number)<1, then we have pulled off + the leading zero; i.e. 0.231 -> .231 -- this is still fine + for Tcl though... +} { + set string [string trimleft $string 0] + + if {$string eq ""} { + return 0 + } + + return $string +} + + ad_proc -public lc_time_fmt_compile { fmt locale