Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.189.2.19 -r1.189.2.20 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 27 Jun 2019 17:36:53 -0000 1.189.2.19 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 1 Jul 2019 14:47:06 -0000 1.189.2.20 @@ -3416,73 +3416,6 @@ return [lindex $list $idx] } -ad_proc -public util::content_size_pretty { - {-size "0"} - {-precision "1"} - {-standard "decimal"} -} { - Transforms data size, provided in non-negative bytes, to KB, MB... up to YB. - - @param size Size in bytes - @param precision Numbers in the fractional part - @param standard Standard to use for binary prefix. Three standards are - supported currently by this proc: - - decimal (default): SI (base-10, 1000 B = 1kB) - - binary: IEC (base-2, 1024 B = 1KiB) - - legacy: JEDEC (base-2, 1024 B = 1KB) - - @return Size in given standard units (e.g. '5.2 MB') - - @author Héctor Romojaro - @creation-date 2019-06-25 -} { - switch $standard { - decimal { - # - # SI (base-10, 1000 B = 1KB) - # - set div 1000 - set units [list B kB MB GB TB PB EB ZB YB] - } - binary { - # - # IEC (base-2, 1024 B = 1KiB) - # - set div 1024 - set units [list B KiB MiB GiB TiB PiB EiB ZiB YiB] - } - legacy { - # - # JEDEC (base-2, 1024 B = 1KB) - # - set div 1024 - set units [list B KB MB GB TB PB EB ZB YB] - } - default { - return "Unknown value $standard for -standard option" - } - } - - if {$size eq ""} { - set size 0 - } - - set len [string length $size] - - if {$size < $div} { - set size_pretty [format "%s B" $size] - } else { - set unit [expr {($len - 1) / 3}] - set size_pretty [format "%.${precision}f %s" [expr {$size / pow($div,$unit)}] [lindex $units $unit]] - } - # - # Localize dot/comma just before return - # - set size_pretty "[lc_numeric [lindex $size_pretty 0]] [lindex $size_pretty 1]" - - return $size_pretty -} - ad_proc -public util::age_pretty { -timestamp_ansi:required -sysdate_ansi:required