From ae940538afe212c7d1024f76373e8cb6c5133d70 Mon Sep 17 00:00:00 2001 From: magnolia61 Date: Sat, 12 Jan 2019 20:50:29 +0100 Subject: [PATCH] Add freeform relative date for 'This Fiscal Year' --- CRM/Utils/Date.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 4223ab35eff..2d00ceba820 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -1247,13 +1247,19 @@ 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':