fix: time_of_day reminder time stored as UTC, displayed as local
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main
parent
ee795237db
commit
439754b9ba
|
|
@ -167,10 +167,10 @@ class EventForm extends Component
|
||||||
{
|
{
|
||||||
if (empty($this->customReminderTime)) return;
|
if (empty($this->customReminderTime)) return;
|
||||||
|
|
||||||
$this->reminders[] = [
|
$type = $this->customReminderType ?: 'time_of_day';
|
||||||
'type' => $this->customReminderType ?: 'time_of_day',
|
$time = $this->localTimeToUtc($this->customReminderTime);
|
||||||
'time' => $this->customReminderTime,
|
|
||||||
];
|
$this->reminders[] = ['type' => $type, 'time' => $time];
|
||||||
|
|
||||||
$this->customReminderTime = '';
|
$this->customReminderTime = '';
|
||||||
$this->customReminderType = 'time_of_day';
|
$this->customReminderType = 'time_of_day';
|
||||||
|
|
@ -178,6 +178,10 @@ class EventForm extends Component
|
||||||
|
|
||||||
public function addReminder(string $type, ?int $minutes = null, ?string $time = null): void
|
public function addReminder(string $type, ?int $minutes = null, ?string $time = null): void
|
||||||
{
|
{
|
||||||
|
if ($time !== null && in_array($type, ['time_of_day', 'day_before'])) {
|
||||||
|
$time = $this->localTimeToUtc($time);
|
||||||
|
}
|
||||||
|
|
||||||
$this->reminders[] = array_filter([
|
$this->reminders[] = array_filter([
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'minutes' => $minutes,
|
'minutes' => $minutes,
|
||||||
|
|
@ -185,6 +189,12 @@ class EventForm extends Component
|
||||||
], fn($v) => $v !== null);
|
], fn($v) => $v !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function localTimeToUtc(string $localTime): string
|
||||||
|
{
|
||||||
|
$tz = auth()->user()->timezone ?? 'UTC';
|
||||||
|
return \Carbon\Carbon::createFromFormat('H:i', $localTime, $tz)->utc()->format('H:i');
|
||||||
|
}
|
||||||
|
|
||||||
public function removeReminder(int $i): void
|
public function removeReminder(int $i): void
|
||||||
{
|
{
|
||||||
array_splice($this->reminders, $i, 1);
|
array_splice($this->reminders, $i, 1);
|
||||||
|
|
|
||||||
|
|
@ -215,9 +215,9 @@
|
||||||
@else {{ $r['minutes'] ?? 30 }}{{ t('events.reminder_min_before') }}
|
@else {{ $r['minutes'] ?? 30 }}{{ t('events.reminder_min_before') }}
|
||||||
@endif
|
@endif
|
||||||
@elseif(($r['type'] ?? '') === 'time_of_day')
|
@elseif(($r['type'] ?? '') === 'time_of_day')
|
||||||
{{ t('events.reminder_on_day_prefix') }}{{ $r['time'] ?? '' }}{{ t('events.reminder_clock_suffix') }}
|
{{ t('events.reminder_on_day_prefix') }}{{ isset($r['time']) ? \Carbon\Carbon::createFromFormat('H:i', $r['time'], 'UTC')->setTimezone(auth()->user()->timezone ?? 'UTC')->format('H:i') : '' }}{{ t('events.reminder_clock_suffix') }}
|
||||||
@else
|
@else
|
||||||
{{ t('events.reminder_prev_day_prefix') }}{{ $r['time'] ?? '' }}{{ t('events.reminder_clock_suffix') }}
|
{{ t('events.reminder_prev_day_prefix') }}{{ isset($r['time']) ? \Carbon\Carbon::createFromFormat('H:i', $r['time'], 'UTC')->setTimezone(auth()->user()->timezone ?? 'UTC')->format('H:i') : '' }}{{ t('events.reminder_clock_suffix') }}
|
||||||
@endif
|
@endif
|
||||||
</span>
|
</span>
|
||||||
<button wire:click="removeReminder({{ $i }})" type="button"
|
<button wire:click="removeReminder({{ $i }})" type="button"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue