diff --git a/app/Livewire/Project/Database/BackupExecutions.php b/app/Livewire/Project/Database/BackupExecutions.php index 7eef1a539..3fc721fda 100644 --- a/app/Livewire/Project/Database/BackupExecutions.php +++ b/app/Livewire/Project/Database/BackupExecutions.php @@ -117,29 +117,6 @@ class BackupExecutions extends Component return null; } - public function getServerTimezone() - { - $server = $this->server(); - if (! $server) { - return 'UTC'; - } - - return $server->settings->server_timezone; - } - - public function formatDateInServerTimezone($date) - { - $serverTimezone = $this->getServerTimezone(); - $dateObj = new \DateTime($date); - try { - $dateObj->setTimezone(new \DateTimeZone($serverTimezone)); - } catch (\Exception) { - $dateObj->setTimezone(new \DateTimeZone('UTC')); - } - - return $dateObj->format('Y-m-d H:i:s T'); - } - public function render() { return view('livewire.project.database.backup-executions', [ diff --git a/app/Livewire/Project/Shared/ScheduledTask/Executions.php b/app/Livewire/Project/Shared/ScheduledTask/Executions.php index 74eac7132..6f62a5b5b 100644 --- a/app/Livewire/Project/Shared/ScheduledTask/Executions.php +++ b/app/Livewire/Project/Shared/ScheduledTask/Executions.php @@ -141,17 +141,4 @@ class Executions extends Component return $lines->count() > ($this->currentPage * $this->logsPerPage); } - - public function formatDateInServerTimezone($date) - { - $serverTimezone = $this->serverTimezone; - $dateObj = new \DateTime($date); - try { - $dateObj->setTimezone(new \DateTimeZone($serverTimezone)); - } catch (\Exception) { - $dateObj->setTimezone(new \DateTimeZone('UTC')); - } - - return $dateObj->format('Y-m-d H:i:s T'); - } } diff --git a/bootstrap/helpers/timezone.php b/bootstrap/helpers/timezone.php new file mode 100644 index 000000000..96d9ba6cf --- /dev/null +++ b/bootstrap/helpers/timezone.php @@ -0,0 +1,42 @@ +setTimezone(new \DateTimeZone($serverTimezone)); + } catch (\Exception) { + $dateObj->setTimezone(new \DateTimeZone('UTC')); + } + + return $dateObj->format('Y-m-d H:i:s T'); +} + +function calculateDuration($startDate, $endDate = null) +{ + if (! $endDate) { + return null; + } + + $start = new \DateTime($startDate); + $end = new \DateTime($endDate); + $interval = $start->diff($end); + + if ($interval->days > 0) { + return $interval->format('%dd %Hh %Im %Ss'); + } elseif ($interval->h > 0) { + return $interval->format('%Hh %Im %Ss'); + } else { + return $interval->format('%Im %Ss'); + } +} diff --git a/resources/views/livewire/project/application/deployment/index.blade.php b/resources/views/livewire/project/application/deployment/index.blade.php index 3fa52b7f3..0555f90d7 100644 --- a/resources/views/livewire/project/application/deployment/index.blade.php +++ b/resources/views/livewire/project/application/deployment/index.blade.php @@ -32,135 +32,96 @@ @forelse ($deployments as $deployment)