From 8216b97ff33043b60884899a81bcd4fd7edce04f Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Jan 2015 11:57:56 +0100 Subject: [PATCH] feature #3345: Set Date.now as max for accounting --- src/sunstone/public/js/sunstone.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 05fdf43a7b..ea54851e70 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -5399,10 +5399,16 @@ function fillAccounting(div, req, response, no_table) { var start = new Date(options.start_time * 1000); start.setUTCHours(0,0,0,0); - var end = new Date(); + var end; + var now = new Date(); - if(options.end_time != undefined && options.end_time != -1){ - var end = new Date(options.end_time * 1000) + if (options.end_time != undefined && options.end_time != -1) { + end = new Date(options.end_time * 1000) + if (end > now) { + end = now; + } + } else { + end = now; } // granularity of 1 day @@ -5419,6 +5425,10 @@ function fillAccounting(div, req, response, no_table) { tmp_time.setUTCDate( tmp_time.getUTCDate() + 1 ); } + if (tmp_time > now) { + times.push(now.getTime()); + } + //-------------------------------------------------------------------------- // Flot options //--------------------------------------------------------------------------