Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Added page to debug time zone issue #946

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/Livewire/Debug/Timezone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Livewire\Debug;

use App\Settings\GeneralSettings;
use Livewire\Attributes\Layout;
use Livewire\Component;

#[Layout('layouts.debug')]
class Timezone extends Component
{
public $settings;

public function mount()
{
$settings = new GeneralSettings();

$this->settings = $settings->toArray();
}

public function render()
{
return view('livewire.debug.timezone');
}
}
18 changes: 18 additions & 0 deletions app/View/Components/DebugLayout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class DebugLayout extends Component
{
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('layouts.app');
}
}

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resources/css/app.css": {
"file": "assets/app-a1b0d14f.css",
"file": "assets/app-2a095b76.css",
"isEntry": true,
"src": "resources/css/app.css"
},
Expand Down
28 changes: 28 additions & 0 deletions resources/views/layouts/debug.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Timezone - {{ config('app.name') }}</title>

{{-- Fonts --}}
<link href="{{ asset('fonts/inter/inter.css') }}" rel="stylesheet" />

{{-- Styles --}}
@filamentStyles
@vite('resources/css/app.css')
</head>
<body class="min-h-screen antialiased bg-gray-50 text-gray-950">
<main class="max-w-xl p-4 mx-auto space-y-4 sm:p-6 lg:p-8 sm:space-y-8">
@if (isset($header))
{{ $header }}
@endif

{{ $slot }}
</main>

{{-- Scripts --}}
@filamentScripts
</body>
</html>
56 changes: 56 additions & 0 deletions resources/views/livewire/debug/timezone.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<div wire:poll.1s>
<x-slot name="header">
<header>
<div>
<h1 class="text-xl font-bold tracking-tight text-gray-950 sm:text-2xl">Debug Time Zone - {{ config('app.name') }}</h1>

<p class="mt-1 text-sm font-medium">
The purpose of this page is to help debut the current issues around time zones and local time. The table below displays an output of the applications current configuration.
</p>
</div>
</header>
</x-slot>

<div class="space-y-6">
<div class="overflow-hidden bg-white shadow sm:rounded-md">
<div class="p-4 bg-white border-b border-gray-200 sm:px-6">
<h3 class="text-base font-semibold leading-6 text-gray-900">Timezone</h3>
</div>

<ul role="list" class="divide-y divide-gray-200">
<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">PHP time zone</p>
<p class="text-sm text-gray-500 truncate">{{ date_default_timezone_get() }}</p>
</li>

<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">App time zone</p>
<p class="text-sm text-gray-500 truncate">{{ config('app.timezone') }}</p>
</li>

<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">Settings time zone</p>
<p class="text-sm text-gray-500 truncate">{{ $settings['timezone'] }} ({{ \Carbon\Carbon::create($settings['timezone'])->format('P') }})</p>
</li>
</ul>
</div>

<div class="overflow-hidden bg-white shadow sm:rounded-md">
<div class="p-4 bg-white border-b border-gray-200 sm:px-6">
<h3 class="text-base font-semibold leading-6 text-gray-900">Time</h3>
</div>

<ul role="list" class="divide-y divide-gray-200">
<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">UTC time</p>
<p class="text-sm text-gray-500 truncate">{{ \Carbon\Carbon::now() }}</p>
</li>

<li class="px-4 py-4 sm:px-6">
<p class="text-sm font-medium text-gray-900">Local time</p>
<p class="text-sm text-gray-500 truncate">{{ \Carbon\Carbon::now()->timezone($settings['timezone'] ?? 'UTC') }}</p>
</li>
</ul>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions routes/debug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

use App\Livewire\Debug\Timezone as DebugTimezone;
use Illuminate\Support\Facades\Route;

Route::get('/debug/timezone', DebugTimezone::class)
->name('debug.timezone');
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
return redirect('/admin/login');
})->name('login');

require __DIR__.'/debug.php';

if (app()->isLocal()) {
require __DIR__.'/test.php';
}