Settable timezones with cachet config
This commit is contained in:
@@ -40,7 +40,7 @@ class ReportIncidentCommandHandler
|
|||||||
|
|
||||||
// The incident occurred at a different time.
|
// The incident occurred at a different time.
|
||||||
if ($command->incident_date) {
|
if ($command->incident_date) {
|
||||||
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
|
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
|
||||||
|
|
||||||
$incident->update([
|
$incident->update([
|
||||||
'created_at' => $incidentDate,
|
'created_at' => $incidentDate,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ReportMaintenanceCommandHandler
|
|||||||
public function handle(ReportMaintenanceCommand $command)
|
public function handle(ReportMaintenanceCommand $command)
|
||||||
{
|
{
|
||||||
// TODO: Add validation to scheduledAt
|
// TODO: Add validation to scheduledAt
|
||||||
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, Setting::get('app_timezone'))
|
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, config('cachet.timezone'))
|
||||||
->setTimezone(Config::get('app.timezone'));
|
->setTimezone(Config::get('app.timezone'));
|
||||||
|
|
||||||
$maintenanceEvent = Incident::create([
|
$maintenanceEvent = Incident::create([
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class UpdateIncidentCommandHandler
|
|||||||
|
|
||||||
// The incident occurred at a different time.
|
// The incident occurred at a different time.
|
||||||
if ($command->incident_date) {
|
if ($command->incident_date) {
|
||||||
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));
|
$incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone'));
|
||||||
|
|
||||||
$incident->update([
|
$incident->update([
|
||||||
'created_at' => $incidentDate,
|
'created_at' => $incidentDate,
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class ScheduleController extends Controller
|
|||||||
{
|
{
|
||||||
$scheduleData = Binput::get('incident');
|
$scheduleData = Binput::get('incident');
|
||||||
// Parse the schedule date.
|
// Parse the schedule date.
|
||||||
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], Setting::get('app_timezone'))
|
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], config('cachet.timezone'))
|
||||||
->setTimezone(Config::get('app.timezone'));
|
->setTimezone(Config::get('app.timezone'));
|
||||||
|
|
||||||
if ($scheduledAt->isPast()) {
|
if ($scheduledAt->isPast()) {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class StatusPageController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$incidentDays = range(0, $daysToShow);
|
$incidentDays = range(0, $daysToShow);
|
||||||
}
|
}
|
||||||
$dateTimeZone = Setting::get('app_timezone');
|
$dateTimeZone = config('cachet.timezone');
|
||||||
|
|
||||||
$incidentVisiblity = Auth::check() ? 0 : 1;
|
$incidentVisiblity = Auth::check() ? 0 : 1;
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ class Timezone
|
|||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if ($tz = $request->header('Time-Zone')) {
|
if ($tz = $request->header('Time-Zone')) {
|
||||||
app('config')->set('app.timezone', $tz);
|
app('config')->set('cachet.timezone', $tz);
|
||||||
Setting::set('app_timezone', $tz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class ConfigServiceProvider extends ServiceProvider
|
|||||||
// Get app custom configuration.
|
// Get app custom configuration.
|
||||||
$appDomain = Setting::get('app_domain');
|
$appDomain = Setting::get('app_domain');
|
||||||
$appLocale = Setting::get('app_locale');
|
$appLocale = Setting::get('app_locale');
|
||||||
|
$appTimezone = Setting::get('app_timezone');
|
||||||
|
|
||||||
// Setup Cors.
|
// Setup Cors.
|
||||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||||
@@ -55,6 +56,7 @@ class ConfigServiceProvider extends ServiceProvider
|
|||||||
// Override default app values.
|
// Override default app values.
|
||||||
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
||||||
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
|
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
|
||||||
|
$this->app->config->set('cachet.timezone', $appTimezone ?: $this->app->config->get('cachet.timezone'));
|
||||||
|
|
||||||
// Set custom lang.
|
// Set custom lang.
|
||||||
$this->app->translator->setLocale($appLocale);
|
$this->app->translator->setLocale($appLocale);
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cachet Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The timezone Cachet uses for converting timezones on saving.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user