Some changes in the charts and range thing.

This commit is contained in:
James Cole
2014-07-08 07:51:25 +02:00
parent c7d3ef6a97
commit 5e8cfb512b
7 changed files with 96 additions and 11 deletions

View 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];
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Firefly\Helper\Toolkit;
class ToolkitInterface {
}