mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 05:28:18 +01:00
Settable timezones with cachet config
This commit is contained in:
parent
ce8e710173
commit
a288f84fc5
@ -40,7 +40,7 @@ class ReportIncidentCommandHandler
|
||||
|
||||
// The incident occurred at a different time.
|
||||
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([
|
||||
'created_at' => $incidentDate,
|
||||
|
@ -30,7 +30,7 @@ class ReportMaintenanceCommandHandler
|
||||
public function handle(ReportMaintenanceCommand $command)
|
||||
{
|
||||
// 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'));
|
||||
|
||||
$maintenanceEvent = Incident::create([
|
||||
|
@ -35,7 +35,7 @@ class UpdateIncidentCommandHandler
|
||||
|
||||
// The incident occurred at a different time.
|
||||
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([
|
||||
'created_at' => $incidentDate,
|
||||
|
@ -140,7 +140,7 @@ class ScheduleController extends Controller
|
||||
{
|
||||
$scheduleData = Binput::get('incident');
|
||||
// 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'));
|
||||
|
||||
if ($scheduledAt->isPast()) {
|
||||
|
@ -55,7 +55,7 @@ class StatusPageController extends Controller
|
||||
} else {
|
||||
$incidentDays = range(0, $daysToShow);
|
||||
}
|
||||
$dateTimeZone = Setting::get('app_timezone');
|
||||
$dateTimeZone = config('cachet.timezone');
|
||||
|
||||
$incidentVisiblity = Auth::check() ? 0 : 1;
|
||||
|
||||
|
@ -28,8 +28,7 @@ class Timezone
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($tz = $request->header('Time-Zone')) {
|
||||
app('config')->set('app.timezone', $tz);
|
||||
Setting::set('app_timezone', $tz);
|
||||
app('config')->set('cachet.timezone', $tz);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -32,6 +32,7 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
// Get app custom configuration.
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
$appTimezone = Setting::get('app_timezone');
|
||||
|
||||
// Setup Cors.
|
||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||
@ -55,6 +56,7 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
// Override default app values.
|
||||
$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('cachet.timezone', $appTimezone ?: $this->app->config->get('cachet.timezone'));
|
||||
|
||||
// Set custom lang.
|
||||
$this->app->translator->setLocale($appLocale);
|
||||
|
24
config/cachet.php
Normal file
24
config/cachet.php
Normal file
@ -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',
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user