Code refactoring
This commit is contained in:
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use Date;
|
|
||||||
use DateTimeZone;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Carbon\CarbonPeriod;
|
|
||||||
use App\Traits\SearchString;
|
use App\Traits\SearchString;
|
||||||
|
use App\Utilities\Date;
|
||||||
|
use Carbon\CarbonPeriod;
|
||||||
|
|
||||||
trait DateTime
|
trait DateTime
|
||||||
{
|
{
|
||||||
@ -61,13 +59,24 @@ trait DateTime
|
|||||||
|
|
||||||
public function getTimezones()
|
public function getTimezones()
|
||||||
{
|
{
|
||||||
return collect(DateTimeZone::listIdentifiers())
|
// The list of available timezone groups to use.
|
||||||
->mapWithKeys(function ($timezone) {
|
$use_zones = ['Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'];
|
||||||
return [$timezone => Str::after($timezone, '/')];
|
|
||||||
|
// Get the list of time zones from the server.
|
||||||
|
$zones = \DateTimeZone::listIdentifiers();
|
||||||
|
|
||||||
|
return collect($zones)
|
||||||
|
->mapWithKeys(function ($timezone) use ($use_zones) {
|
||||||
|
if (! in_array(str($timezone)->before('/'), $use_zones)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$timezone => str($timezone)->after('/')->value()];
|
||||||
})
|
})
|
||||||
->groupBy(function ($item, $key) {
|
->groupBy(function ($item, $key) {
|
||||||
return Str::before($key, '/');
|
return str($key)->before('/')->value();
|
||||||
}, preserveKeys: true);
|
}, preserveKeys: true)
|
||||||
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFinancialStart($year = null)
|
public function getFinancialStart($year = null)
|
||||||
|
Reference in New Issue
Block a user