From 161cd05c63acb5c200adf65572cad2db2a259a61 Mon Sep 17 00:00:00 2001 From: smos Date: Thu, 15 Jul 2010 20:01:05 +0200 Subject: Remove debugging line Improve the scale so that it matches up the length of the period. Style fixes --- usr/local/www/status_rrd_graph.php | 4 ++-- usr/local/www/status_rrd_graph_img.php | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'usr') diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php index cefbbb2..441aa3a 100755 --- a/usr/local/www/status_rrd_graph.php +++ b/usr/local/www/status_rrd_graph.php @@ -197,11 +197,11 @@ function get_dates($curperiod, $graph) { break; case "year": $start = mktime(0, 0, 0, 1, 0, ($curyear - $offset)); - $end = mktime(0, 0, 0, 1, 0, (($curyear - $offset) +1)); + $end = mktime(0, 0, 0, 1, 1, (($curyear - $offset) +1)); break; case "4year": $start = mktime(0, 0, 0, 1, 0, (($curyear - 3) - $offset)); - $end = mktime(0, 0, 0, 1, 0, (($curyear - $offset) +1)); + $end = mktime(0, 0, 0, 1, 1, (($curyear - $offset) +1)); break; } $dates = array(); diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php index ffaea00..5000b5d 100644 --- a/usr/local/www/status_rrd_graph_img.php +++ b/usr/local/www/status_rrd_graph_img.php @@ -95,7 +95,7 @@ $archives = array(); $archives[1] = 1000; $archives[5] = 1000; $archives[60] = 1000; -$archives[720] = 1000; +$archives[720] = 3000; $defOptions = array( 'to' => 1, @@ -122,7 +122,7 @@ foreach($scales as $scalelength => $value) { } } -log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds"); +// log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds"); /* Deduce a interface if possible and use the description */ $curif = split("-", $curdatabase); @@ -233,11 +233,11 @@ function timeDiff($time, $opt = array()) { // Init an empty string $str = ''; // To or From computation - $diff = ($opt['to'] >= $time) ? $opt['to']-$time : $time-$opt['to']; + $diff = ($opt['to'] >= $time) ? $opt['to'] - $time : $time - $opt['to']; // An array of label => periods of seconds; $periods = array( 'decade' => 315569260, - 'year' => 31556926, + 'year' => 31539600, 'month' => 2629744, 'week' => 604800, 'day' => 86400, @@ -245,21 +245,22 @@ function timeDiff($time, $opt = array()) { 'minute' => 60, 'second' => 1 ); + // 31539600, 31556926, 31622400 // Round to precision if ($opt['precision'] != 'second') - $diff = round(($diff/$periods[$opt['precision']])) * $periods[$opt['precision']]; + $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']]; // Report the value is 'less than 1 ' precision period away - (0 == $diff) && ($str = 'less than 1 '.$opt['precision']); + (0 == $diff) && ($str = 'less than 1 ' .$opt['precision']); // Loop over each period foreach ($periods as $label => $value) { // Stitch together the time difference string - (($x=floor($diff/$value))&&$opt['parts']--) && $str.=($str?$opt['separator']:'').($x.' '.$label.($x > 1?'s':'')); + (($x = floor($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x .' '. $label. ($x > 1 ? 's' : '')); // Stop processing if no more parts are going to be reported. if ($opt['parts'] == 0 || $label == $opt['precision']) break; // Get ready for the next pass - $diff -= $x*$value; + $diff -= $x * $value; } - $opt['distance'] && $str.=($str&&$opt['to'] >= $time)?' ago':' away'; + $opt['distance'] && $str .= ($str && $opt['to'] >= $time) ? ' ago' : ' away'; return $str; } -- cgit v1.1