show cron execution with timezone

This commit is contained in:
ayntk-ai
2024-08-16 16:01:57 +02:00
parent dab5f0fe09
commit 883a52afe9
2 changed files with 24 additions and 3 deletions

View File

@@ -27,11 +27,28 @@ class Executions extends Component
$this->selectedKey = $key; $this->selectedKey = $key;
} }
public function server()
{
return $this->destination->server;
}
public function getServerTimezone() public function getServerTimezone()
{ {
$server = data_get($this, 'destination.server'); $server = $this->server();
$serverTimezone = $server->settings->server_timezone; $serverTimezone = $server->settings->server_timezone ?: config('app.timezone');
ray('Server Timezone:', $serverTimezone); ray('Server Timezone:', $serverTimezone);
return $serverTimezone; return $serverTimezone;
} }
public function formatDateInServerTimezone($date)
{
$serverTimezone = $this->getServerTimezone();
$dateObj = new \DateTime($date);
try {
$dateObj->setTimezone(new \DateTimeZone($serverTimezone));
} catch (\Exception $e) {
ray('Invalid timezone:', $serverTimezone);
}
return $dateObj->format('Y-m-d H:i:s T');
}
} }

View File

@@ -40,6 +40,7 @@ class Index extends Component
'settings.is_auto_update_enabled' => 'boolean', 'settings.is_auto_update_enabled' => 'boolean',
'auto_update_frequency' => 'string', 'auto_update_frequency' => 'string',
'update_check_frequency' => 'string', 'update_check_frequency' => 'string',
'settings.instance_timezone' => 'required|string|timezone',
]; ];
protected $validationAttributes = [ protected $validationAttributes = [
@@ -54,6 +55,8 @@ class Index extends Component
'update_check_frequency' => 'Update Check Frequency', 'update_check_frequency' => 'Update Check Frequency',
]; ];
public $timezones;
public function mount() public function mount()
{ {
if (isInstanceAdmin()) { if (isInstanceAdmin()) {
@@ -65,6 +68,7 @@ class Index extends Component
$this->is_api_enabled = $this->settings->is_api_enabled; $this->is_api_enabled = $this->settings->is_api_enabled;
$this->auto_update_frequency = $this->settings->auto_update_frequency; $this->auto_update_frequency = $this->settings->auto_update_frequency;
$this->update_check_frequency = $this->settings->update_check_frequency; $this->update_check_frequency = $this->settings->update_check_frequency;
$this->timezones = collect(timezone_identifiers_list())->sort()->values()->toArray();
} else { } else {
return redirect()->route('dashboard'); return redirect()->route('dashboard');
} }
@@ -170,4 +174,4 @@ class Index extends Component
{ {
return view('livewire.settings.index'); return view('livewire.settings.index');
} }
} }