Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.

Commit 86a76d3

Browse files
authored
Merge pull request #60 from phparch/countdown-central-timezone
Update timezone for countdown timer
2 parents 64149ab + 13c2f22 commit 86a76d3

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

app/Models/Conference.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ public function getEndDate(): ?Carbon
7272
return $this->end_date;
7373
}
7474

75+
/**
76+
* Get the start date as an absolute ISO 8601 instant, interpreting the
77+
* stored wall-clock time as the conference timezone (e.g. America/Chicago).
78+
*/
79+
public function getStartInstantIso(): ?string
80+
{
81+
if (! $this->start_date) {
82+
return null;
83+
}
84+
85+
return $this->start_date
86+
->copy()
87+
->shiftTimezone(config('tek.conference.timezone'))
88+
->toIso8601String();
89+
}
90+
7591
/**
7692
* Get the formatted start date.
7793
*/

resources/views/components/hero-section.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class="inline-block py-1 px-3 rounded-full bg-tek-blue-100 dark:bg-tek-blue-800/
2121
opportunities with the PHP community.
2222
</p>
2323
@if($conference && $conference->getStartDate())
24-
<div x-data="countdown('{{ $conference->getStartDate()->toIso8601String() }}')"
24+
<div x-data="countdown('{{ $conference->getStartInstantIso() }}')"
2525
class="bg-white/80 dark:bg-tek-blue-900/30 backdrop-blur-sm border border-tek-blue-200 dark:border-tek-blue-800 rounded-xl p-4 md:p-6 shadow-md max-w-xl"
2626
role="timer"
2727
aria-live="polite"

tests/Feature/ConferenceModelTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ public function test_conference_direct_attribute_access(): void
6767
$this->assertEquals('2026-07-02', $conference->end_date->format('Y-m-d'));
6868
}
6969

70+
/**
71+
* The start instant ISO string should be expressed against the configured
72+
* conference timezone (Central time), not the application's UTC default.
73+
*/
74+
public function test_start_instant_iso_uses_conference_timezone(): void
75+
{
76+
config()->set('tek.conference.timezone', 'America/Chicago');
77+
78+
$conference = Conference::create([
79+
'uuid' => 'test-uuid-instant',
80+
'name' => 'Instant Conference',
81+
'start_date' => '2026-05-19 09:00:00',
82+
'end_date' => '2026-05-21 17:00:00',
83+
]);
84+
85+
// 9:00 AM Central in May (CDT, UTC-5) is 14:00 UTC.
86+
$this->assertEquals('2026-05-19T09:00:00-05:00', $conference->getStartInstantIso());
87+
}
88+
7089
/**
7190
* Test the formatted date range method.
7291
*/

0 commit comments

Comments
 (0)