Switch back to jenseggers/date
This commit is contained in:
@@ -14,9 +14,9 @@ namespace CachetHQ\Cachet\Foundation\Providers;
|
|||||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||||
use CachetHQ\Cachet\Settings\Cache;
|
use CachetHQ\Cachet\Settings\Cache;
|
||||||
use CachetHQ\Cachet\Settings\Repository;
|
use CachetHQ\Cachet\Settings\Repository;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the config service provider class.
|
* This is the config service provider class.
|
||||||
@@ -67,7 +67,7 @@ class ConfigServiceProvider extends ServiceProvider
|
|||||||
if ($appLocale = $this->app->config->get('setting.app_locale')) {
|
if ($appLocale = $this->app->config->get('setting.app_locale')) {
|
||||||
$this->app->config->set('app.locale', $appLocale);
|
$this->app->config->set('app.locale', $appLocale);
|
||||||
$this->app->translator->setLocale($appLocale);
|
$this->app->translator->setLocale($appLocale);
|
||||||
Carbon::setLocale($appLocale);
|
Date::setLocale($appLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the timezone.
|
// Set the timezone.
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ use CachetHQ\Cachet\Models\Component;
|
|||||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||||
use CachetHQ\Cachet\Models\Incident;
|
use CachetHQ\Cachet\Models\Incident;
|
||||||
use CachetHQ\Cachet\Models\Subscriber;
|
use CachetHQ\Cachet\Models\Subscriber;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the dashboard controller class.
|
* This is the dashboard controller class.
|
||||||
@@ -34,7 +34,7 @@ class DashboardController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Start date.
|
* Start date.
|
||||||
*
|
*
|
||||||
* @var \Carbon\Carbon
|
* @var \Jenssegers\Date\Date
|
||||||
*/
|
*/
|
||||||
protected $startDate;
|
protected $startDate;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ class DashboardController extends Controller
|
|||||||
{
|
{
|
||||||
$this->feed = $feed;
|
$this->feed = $feed;
|
||||||
$this->guard = $guard;
|
$this->guard = $guard;
|
||||||
$this->startDate = Carbon::now();
|
$this->startDate = new Date();
|
||||||
$this->dateTimeZone = Config::get('cachet.timezone');
|
$this->dateTimeZone = Config::get('cachet.timezone');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,13 +131,13 @@ class DashboardController extends Controller
|
|||||||
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
|
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
|
||||||
$this->startDate->format('Y-m-d').' 23:59:59',
|
$this->startDate->format('Y-m-d').' 23:59:59',
|
||||||
])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
|
||||||
return (new Carbon($incident->occurred_at))
|
return (new Date($incident->occurred_at))
|
||||||
->setTimezone($this->dateTimeZone)->toDateString();
|
->setTimezone($this->dateTimeZone)->toDateString();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add in days that have no incidents
|
// Add in days that have no incidents
|
||||||
foreach (range(0, 30) as $i) {
|
foreach (range(0, 30) as $i) {
|
||||||
$date = (new Carbon($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
|
$date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
|
||||||
|
|
||||||
if (!isset($allIncidents[$date->toDateString()])) {
|
if (!isset($allIncidents[$date->toDateString()])) {
|
||||||
$allIncidents[$date->toDateString()] = [];
|
$allIncidents[$date->toDateString()] = [];
|
||||||
@@ -163,13 +163,13 @@ class DashboardController extends Controller
|
|||||||
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
|
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
|
||||||
$this->startDate->format('Y-m-d').' 23:59:59',
|
$this->startDate->format('Y-m-d').' 23:59:59',
|
||||||
])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) {
|
])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) {
|
||||||
return (new Carbon($incident->created_at))
|
return (new Date($incident->created_at))
|
||||||
->setTimezone($this->dateTimeZone)->toDateString();
|
->setTimezone($this->dateTimeZone)->toDateString();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add in days that have no incidents
|
// Add in days that have no incidents
|
||||||
foreach (range(0, 30) as $i) {
|
foreach (range(0, 30) as $i) {
|
||||||
$date = (new Carbon($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
|
$date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
|
||||||
|
|
||||||
if (!isset($allSubscribers[$date->toDateString()])) {
|
if (!isset($allSubscribers[$date->toDateString()])) {
|
||||||
$allSubscribers[$date->toDateString()] = [];
|
$allSubscribers[$date->toDateString()] = [];
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ use CachetHQ\Cachet\Models\Metric;
|
|||||||
use CachetHQ\Cachet\Models\Schedule;
|
use CachetHQ\Cachet\Models\Schedule;
|
||||||
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
||||||
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use GrahamCampbell\Binput\Facades\Binput;
|
use GrahamCampbell\Binput\Facades\Binput;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
@@ -27,6 +26,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Response;
|
use Illuminate\Support\Facades\Response;
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,14 +45,14 @@ class StatusPageController extends AbstractApiController
|
|||||||
*/
|
*/
|
||||||
public function showIndex()
|
public function showIndex()
|
||||||
{
|
{
|
||||||
$today = Carbon::now();
|
$today = Date::now();
|
||||||
$startDate = Carbon::now();
|
$startDate = Date::now();
|
||||||
|
|
||||||
// Check if we have another starting date
|
// Check if we have another starting date
|
||||||
if (Binput::has('start_date')) {
|
if (Binput::has('start_date')) {
|
||||||
try {
|
try {
|
||||||
// If date provided is valid
|
// If date provided is valid
|
||||||
$oldDate = Carbon::createFromFormat('Y-m-d', Binput::get('start_date'));
|
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
|
||||||
|
|
||||||
// If trying to get a future date fallback to today
|
// If trying to get a future date fallback to today
|
||||||
if ($today->gt($oldDate)) {
|
if ($today->gt($oldDate)) {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
namespace CachetHQ\Cachet\Http\Middleware;
|
namespace CachetHQ\Cachet\Http\Middleware;
|
||||||
|
|
||||||
use CachetHQ\Cachet\Settings\Repository as SettingsRepository;
|
use CachetHQ\Cachet\Settings\Repository as SettingsRepository;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the localize middleware class.
|
* This is the localize middleware class.
|
||||||
@@ -82,7 +82,7 @@ class Localize
|
|||||||
}
|
}
|
||||||
|
|
||||||
app('translator')->setLocale($userLanguage);
|
app('translator')->setLocale($userLanguage);
|
||||||
Carbon::setLocale($userLanguage);
|
Date::setLocale($userLanguage);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Repositories\Metric;
|
|||||||
|
|
||||||
use CachetHQ\Cachet\Models\Metric;
|
use CachetHQ\Cachet\Models\Metric;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the pgsql repository class.
|
* This is the pgsql repository class.
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Repositories\Metric;
|
|||||||
|
|
||||||
use CachetHQ\Cachet\Models\Metric;
|
use CachetHQ\Cachet\Models\Metric;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the sqlite repository class.
|
* This is the sqlite repository class.
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace CachetHQ\Cachet\Services\Dates;
|
namespace CachetHQ\Cachet\Services\Dates;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the date factory class.
|
* This is the date factory class.
|
||||||
@@ -62,7 +62,7 @@ class DateFactory
|
|||||||
*/
|
*/
|
||||||
public function create($format, $time)
|
public function create($format, $time)
|
||||||
{
|
{
|
||||||
return Carbon::createFromFormat($format, $time, $this->cachetTimezone)->setTimezone($this->appTimezone);
|
return Date::createFromFormat($format, $time, $this->cachetTimezone)->setTimezone($this->appTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +79,7 @@ class DateFactory
|
|||||||
*/
|
*/
|
||||||
public function createNormalized($format, $time)
|
public function createNormalized($format, $time)
|
||||||
{
|
{
|
||||||
return Carbon::createFromFormat($format, $time)->setTimezone($this->appTimezone);
|
return Date::createFromFormat($format, $time)->setTimezone($this->appTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +93,7 @@ class DateFactory
|
|||||||
*/
|
*/
|
||||||
public function make($time = null)
|
public function make($time = null)
|
||||||
{
|
{
|
||||||
return Carbon::parse($time)->setTimezone($this->cachetTimezone);
|
return (new Date($time))->setTimezone($this->cachetTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +103,7 @@ class DateFactory
|
|||||||
*/
|
*/
|
||||||
public function getTimezone()
|
public function getTimezone()
|
||||||
{
|
{
|
||||||
$dateTime = new Carbon();
|
$dateTime = new Date();
|
||||||
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
|
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
|
||||||
|
|
||||||
return $dateTime->format('T');
|
return $dateTime->format('T');
|
||||||
|
|||||||
+2
-2
@@ -9,9 +9,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Request;
|
use Illuminate\Support\Facades\Request;
|
||||||
|
use Jenssegers\Date\Date;
|
||||||
|
|
||||||
if (!function_exists('set_active')) {
|
if (!function_exists('set_active')) {
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +47,7 @@ if (!function_exists('formatted_date')) {
|
|||||||
{
|
{
|
||||||
$dateFormat = Config::get('setting.date_format', 'jS F Y');
|
$dateFormat = Config::get('setting.date_format', 'jS F Y');
|
||||||
|
|
||||||
return Carbon::parse($date)->format($dateFormat);
|
return (new Date($date))->format($dateFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"graham-campbell/exceptions": "^9.1",
|
"graham-campbell/exceptions": "^9.1",
|
||||||
"graham-campbell/markdown": "^7.1",
|
"graham-campbell/markdown": "^7.1",
|
||||||
"guzzlehttp/guzzle": "^6.2.1",
|
"guzzlehttp/guzzle": "^6.2.1",
|
||||||
|
"jenssegers/date": "^3.2",
|
||||||
"laravel/framework": "5.3.*",
|
"laravel/framework": "5.3.*",
|
||||||
"mccool/laravel-auto-presenter": "^4.3",
|
"mccool/laravel-auto-presenter": "^4.3",
|
||||||
"nexmo/client": "@beta",
|
"nexmo/client": "@beta",
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ return [
|
|||||||
GrahamCampbell\Core\CoreServiceProvider::class,
|
GrahamCampbell\Core\CoreServiceProvider::class,
|
||||||
GrahamCampbell\Markdown\MarkdownServiceProvider::class,
|
GrahamCampbell\Markdown\MarkdownServiceProvider::class,
|
||||||
GrahamCampbell\Security\SecurityServiceProvider::class,
|
GrahamCampbell\Security\SecurityServiceProvider::class,
|
||||||
|
Jenssegers\Date\DateServiceProvider::class,
|
||||||
McCool\LaravelAutoPresenter\AutoPresenterServiceProvider::class,
|
McCool\LaravelAutoPresenter\AutoPresenterServiceProvider::class,
|
||||||
PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider::class,
|
PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider::class,
|
||||||
Roumen\Feed\FeedServiceProvider::class,
|
Roumen\Feed\FeedServiceProvider::class,
|
||||||
|
|||||||
Reference in New Issue
Block a user