From 01d22ff8c69c8c9b335957374635e09aef3851cc Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Fri, 19 May 2017 09:42:51 +0800 Subject: [PATCH] MDL-58991 report_stats: use same date handling on chart rendering This commmit fixes applies the same date handling used on stats table render to the charts render. --- report/stats/locallib.php | 10 ++++++---- report/stats/user.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/report/stats/locallib.php b/report/stats/locallib.php index 7403e6767ab..75b91b680f7 100644 --- a/report/stats/locallib.php +++ b/report/stats/locallib.php @@ -264,7 +264,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) { // bad luck, we can not link other report } else if (empty($param->crosstab)) { foreach ($stats as $stat) { - $a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1); + $a = array(userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone), + $stat->line1); if (isset($stat->line2)) { $a[] = $stat->line2; } @@ -302,7 +303,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) { } } if (!array_key_exists($stat->timeend,$times)) { - $times[$stat->timeend] = userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone); + $times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'), + $CFG->timezone); } } @@ -395,7 +397,7 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0, foreach ($stats as $stat) { // Build the array of formatted times indexed by timestamp used as labels. if (!array_key_exists($stat->timeend, $times)) { - $times[$stat->timeend] = userdate($stat->timeend, get_string('strftimedate'), $CFG->timezone); + $times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone); // Just add the data if the time hasn't been added yet. // The number of lines of data must match the number of labels. @@ -436,7 +438,7 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0, // Build the array of formatted times indexed by timestamp used as labels. if (!array_key_exists($stat->timeend, $times)) { - $times[$stat->timeend] = userdate($stat->timeend, get_string('strftimedate'), $CFG->timezone); + $times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone); } } // Fill empty days with zero to avoid chart errors. diff --git a/report/stats/user.php b/report/stats/user.php index e36c2b4bc21..2d5a5c846af 100644 --- a/report/stats/user.php +++ b/report/stats/user.php @@ -156,7 +156,7 @@ foreach ($stats as $stat) { if (!empty($stat->zerofixed)) { // Don't know why this is necessary, see stats_fix_zeros above - MD continue; } - $a = array(userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone),$stat->line1); + $a = array(userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone), $stat->line1); $a[] = $stat->line2; $a[] = $stat->line3; $table->data[] = $a;