Skip to content
Snippets Groups Projects
Commit 20b48244 authored by Olav Morken's avatar Olav Morken
Browse files

statistics: Handle new year wraparound without year included in log lines.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2049 44740490-163a-0410-bde0-09ae8108e29a
parent 0a04d342
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,21 @@ class sspmod_statistics_LogParser { ...@@ -25,6 +25,21 @@ class sspmod_statistics_LogParser {
public function parseEpoch($line) { public function parseEpoch($line) {
$epoch = strtotime(substr($line, 0, $this->datelength)); $epoch = strtotime(substr($line, 0, $this->datelength));
if ($epoch > time() + 60*60*24*31) {
/*
* More than a month in the future - probably caused by
* the log files missing the year.
* We will therefore subtrackt one year.
*/
$hour = gmdate('H', $epoch);
$minute = gmdate('i', $epoch);
$second = gmdate('s', $epoch);
$month = gmdate('n', $epoch);
$day = gmdate('j', $epoch);
$year = gmdate('Y', $epoch) - 1;
$epoch = gmmktime($hour, $minute, $second, $month, $day, $year);
}
// echo 'debug ' . $line . "\n"; // echo 'debug ' . $line . "\n";
// echo 'debug [' . substr($line, 0, $this->datelength) . '] => [' . $epoch . ']' . "\n"; // echo 'debug [' . substr($line, 0, $this->datelength) . '] => [' . $epoch . ']' . "\n";
return $epoch; return $epoch;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment