Added missing ranges to Navigation, see issue #170

This commit is contained in:
James Cole 2016-02-05 06:56:10 +01:00
parent 581e2ad431
commit bb8ce30552

View File

@ -70,7 +70,7 @@ class Navigation
'1W' => 'addWeek', 'week' => 'addWeek', 'weekly' => 'addWeek', '1W' => 'addWeek', 'week' => 'addWeek', 'weekly' => 'addWeek',
'1M' => 'addMonth', 'month' => 'addMonth', 'monthly' => 'addMonth', '1M' => 'addMonth', 'month' => 'addMonth', 'monthly' => 'addMonth',
'3M' => 'addMonths', 'quarter' => 'addMonths', 'quarterly' => 'addMonths', '6M' => 'addMonths', 'half-year' => 'addMonths', '3M' => 'addMonths', 'quarter' => 'addMonths', 'quarterly' => 'addMonths', '6M' => 'addMonths', 'half-year' => 'addMonths',
'year' => 'addYear', 'yearly' => 'addYear', 'year' => 'addYear', 'yearly' => 'addYear', '1Y' => 'addYear',
]; ];
$modifierMap = [ $modifierMap = [
'quarter' => 3, 'quarter' => 3,
@ -163,6 +163,7 @@ class Navigation
'1Y' => '%Y', '1Y' => '%Y',
'year' => '%Y', 'year' => '%Y',
'yearly' => '%Y', 'yearly' => '%Y',
'6M' => '%B %Y',
]; ];
@ -198,6 +199,7 @@ class Navigation
'quarterly' => 'firstOfQuarter', 'quarterly' => 'firstOfQuarter',
'year' => 'startOfYear', 'year' => 'startOfYear',
'yearly' => 'startOfYear', 'yearly' => 'startOfYear',
'1Y' => 'startOfYear',
]; ];
if (isset($functionMap[$repeatFreq])) { if (isset($functionMap[$repeatFreq])) {
$function = $functionMap[$repeatFreq]; $function = $functionMap[$repeatFreq];
@ -214,6 +216,11 @@ class Navigation
return $date; return $date;
} }
if ($repeatFreq === 'custom') {
return $theDate; // the date is already at the start.
}
throw new FireflyException('Cannot do startOfPeriod for $repeat_freq "' . $repeatFreq . '"'); throw new FireflyException('Cannot do startOfPeriod for $repeat_freq "' . $repeatFreq . '"');
} }
@ -239,12 +246,15 @@ class Navigation
'1M' => 'subMonths', '1M' => 'subMonths',
'monthly' => 'subMonths', 'monthly' => 'subMonths',
'year' => 'subYears', 'year' => 'subYears',
'1Y' => 'subYears',
'yearly' => 'subYears', 'yearly' => 'subYears',
]; ];
$modifierMap = [ $modifierMap = [
'quarter' => 3, 'quarter' => 3,
'3M' => 3,
'quarterly' => 3, 'quarterly' => 3,
'half-year' => 6, 'half-year' => 6,
'6M' => 6,
]; ];
if (isset($functionMap[$repeatFreq])) { if (isset($functionMap[$repeatFreq])) {
$function = $functionMap[$repeatFreq]; $function = $functionMap[$repeatFreq];