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.

This commit is contained in:
root
2026-03-03 16:46:36 -05:00
parent fee07bcceb
commit 0f8a1fa0b1
+16 -1
View File
@@ -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);
}
}