mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Some changes in the charts and range thing.
This commit is contained in:
44
app/lib/Firefly/Helper/Toolkit/Toolkit.php
Normal file
44
app/lib/Firefly/Helper/Toolkit/Toolkit.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Helper\Toolkit;
|
||||
|
||||
|
||||
class Toolkit
|
||||
{
|
||||
|
||||
/**
|
||||
* Based on the preference 'viewRange' and other variables I have not yet thought of,
|
||||
* this method will return a date range that defines the 'current' period of time.
|
||||
*
|
||||
* ie. the current week or month.
|
||||
*
|
||||
* $start is always the past, $end is 'now' or at least later.
|
||||
*/
|
||||
public static function getDateRange()
|
||||
{
|
||||
$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||
$viewRange = $preferences->get('viewRange', 'week');
|
||||
|
||||
// as you can see, this method now only supports "right now":
|
||||
$now = new \Carbon\Carbon;
|
||||
$start = clone $now;
|
||||
$end = clone $now;
|
||||
|
||||
|
||||
switch ($viewRange->data) {
|
||||
case 'week':
|
||||
$start->startOfWeek();
|
||||
$end->endOfWeek();
|
||||
break;
|
||||
default:
|
||||
case 'month':
|
||||
$start->startOfMonth();
|
||||
$end->endOfMonth();
|
||||
break;
|
||||
}
|
||||
return [$start, $end];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
8
app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
Normal file
8
app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Helper\Toolkit;
|
||||
|
||||
|
||||
class ToolkitInterface {
|
||||
|
||||
}
|
Reference in New Issue
Block a user