Skip to content

Commit

Permalink
Fixing daterange variable header when passed through a FilterHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Crumm committed Mar 5, 2014
1 parent c4953be commit 7e28795
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions classes/headers/VariableHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,19 @@ public static function afterParse(&$report) {

$report->options['Variables'][$var] = $params;
}
//if the type is daterange, parse start and end with strtotime
if($params['type'] === 'daterange' && $report->macros[$params['name']]['start'] && $report->macros[$params['name']]['end']) {
$start = date_create($report->macros[$params['name']]['start']);
if(!$start) throw new Exception($params['display']." must have a valid start date.");
date_time_set($start,0,0,0);
$report->macros[$params['name']]['start'] = date_format($start,$params['format']);
$end = date_create($report->macros[$params['name']]['end']);
if(!$end) throw new Exception($params['display']." must have a valid end date.");
date_time_set($end,23,59,59);
$report->macros[$params['name']]['end'] = date_format($end,$params['format']);
}

//if the type is daterange, parse start and end with strtotime
if($params['type'] === 'daterange' && $report->macros[$params['name']][0] && $report->macros[$params['name']][1]) {
$start = date_create($report->macros[$params['name']][0]);
if(!$start) throw new Exception($params['display']." must have a valid start date.");
date_time_set($start,0,0,0);
$report->macros[$params['name']]['start'] = date_format($start,$params['format']);

$end = date_create($report->macros[$params['name']][1]);
if(!$end) throw new Exception($params['display']." must have a valid end date.");
date_time_set($end,23,59,59);
$report->macros[$params['name']]['end'] = date_format($end,$params['format']);
}
}
}

Expand Down

0 comments on commit 7e28795

Please sign in to comment.