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.59 -r1.60 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 27 Nov 2003 15:25:18 -0000 1.59 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 11 Dec 2003 21:39:56 -0000 1.60 @@ -1637,6 +1637,9 @@ ad_proc -public exists_and_not_null { varname } { Returns 1 if the variable name exists in the caller's environment and is not the empty string. + + Note you should enter the variable name, and not the variable value + (varname not $varname which will pass variable varnames value into this function). } { upvar 1 $varname var return [expr { [info exists var] && ![empty_string_p $var] }] @@ -4649,3 +4652,20 @@ regsub -all {\]} $string {\]} string return $string } + +ad_proc -public util::interval_pretty { + {-seconds 0} +} { + Takes a number of seconds and returns a pretty interval of the form "3h 49m 13s" +} { + set result {} + if { $seconds > 0 } { + set hrs [expr $seconds / (60*60)] + set mins [expr ($seconds / 60) % 60] + set secs [expr $seconds % 60] + if { $hrs > 0 } { append result "${hrs}h " } + if { $hrs > 0 || $mins > 0 } { append result "${mins}m " } + append result "${secs}s" + } + return $result +}