From 0f8a1fa0b1a22cd87a451a845fed57b14c1a0b33 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 16:46:36 -0500 Subject: [PATCH] Fixed the date shift by making date-only strings stay in the user timezone instead of being converted from UTC, which caused the one-day rollback. --- app/Services/TimeService.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Services/TimeService.php b/app/Services/TimeService.php index d805bbb..15cd02c 100644 --- a/app/Services/TimeService.php +++ b/app/Services/TimeService.php @@ -167,8 +167,13 @@ class TimeService return null; } - $sourceTz = $sourceTz ?: $this->serverTimezone; $targetTz = $targetTz ?: $this->userTimezone(); + if ($sourceTz === null && $this->isDateOnlyString($value)) { + // Date-only strings should not shift across timezones. + $sourceTz = $targetTz; + } else { + $sourceTz = $sourceTz ?: $this->serverTimezone; + } try { if ($value instanceof Time) { @@ -204,4 +209,14 @@ class TimeService { return (string) ($this->toUTC($value, $fromTz, $format) ?? ''); } + + private function isDateOnlyString($value): bool + { + if (!is_string($value)) { + return false; + } + + $value = trim($value); + return (bool) preg_match('/^\d{4}-\d{2}-\d{2}$/', $value); + } }