From bae54e43b21b732a368426fe1ff4517fc9c3e01a Mon Sep 17 00:00:00 2001 From: Frank Wuerthwein Date: Fri, 8 May 2009 23:45:53 +0000 Subject: Move format_time from rrdFlot into rrdFlotSupport --- src/lib/rrdFlotSupport.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/lib/rrdFlotSupport.js') diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js index ec460fd..3110eda 100644 --- a/src/lib/rrdFlotSupport.js +++ b/src/lib/rrdFlotSupport.js @@ -261,3 +261,41 @@ rrdFlotSelection.prototype.trim_data = function(data_list) { return out_data; }; +// ====================================== +// Miscelabeous helper functions +// ====================================== + +function rfs_format_time(s) { + if (s<120) { + return s+"s"; + } else { + var s60=s%60; + var m=(s-s60)/60; + if ((m<10) && (s60>9)) { + return m+":"+s60+"min"; + } if (m<120) { + return m+"min"; + } else { + var m60=m%60; + var h=(m-m60)/60; + if ((h<12) && (m60>9)) { + return h+":"+m60+"h"; + } if (h<48) { + return h+"h"; + } else { + var h24=h%24; + var d=(h-h24)/24; + if ((d<7) && (h24>0)) { + return d+" days "+h24+"h"; + } if (d<60) { + return d+" days"; + } else { + var d30=d%30; + var mt=(d-d30)/30; + return mt+" months"; + } + } + } + + } +} -- cgit v1.2.3-54-g00ecf