Skip to content

Commit

Permalink
Add freeform relative date for 'This Fiscal Year'
Browse files Browse the repository at this point in the history
  • Loading branch information
magnolia61 committed Jan 23, 2019
1 parent bbb3711 commit a8cc4bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CRM/Utils/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -1247,13 +1247,17 @@ public static function relativeToAbsolute($relativeTerm, $unit) {
$fYear = self::calculateFiscalYear($from['d'], $from['M']);
switch ($relativeTermPrefix) {
case 'this':
if (!is_numeric($relativeTermSuffix)) { $relativeTermSuffix = 0);
$from['Y'] = $fYear;
$fiscalYear = mktime(0, 0, 0, $from['M'], $from['d'] - 1, $from['Y'] + 1);
$fiscalEnd = explode('-', date("Y-m-d", $fiscalYear));

$to['d'] = $fiscalEnd['2'];
$to['M'] = $fiscalEnd['1'];
$to['Y'] = $fiscalEnd['0'];
$to['H'] = 23;
$to['i'] = $to['s'] = 59;
$from = self::intervalAdd('year', (-1 -$relativeTermSuffix), $to);
$from = self::intervalAdd('second', 1, $from);
break;

case 'previous':
Expand Down

0 comments on commit a8cc4bd

Please sign in to comment.