diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-04-03 11:39:21 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2025-04-03 11:39:21 +0000 |
| commit | 58001b32745555963a819cfd88248146e350a75f (patch) | |
| tree | 52abea87f747f113f0c4b8a990e8ce30b71da868 /app/controllers/consultation/admin.php | |
| parent | d75a2847ce4dacfa3f4109954ef906c5e3ed3903 (diff) | |
refine datetime extraction in consultation creator, fixes #5461
Closes #5461
Merge request studip/studip!4095
Diffstat (limited to 'app/controllers/consultation/admin.php')
| -rw-r--r-- | app/controllers/consultation/admin.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 011e424..1876653 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -929,10 +929,24 @@ class Consultation_AdminController extends ConsultationController throw new Exception("Date with index '{$index}' was not submitted properly"); } - return strtotime(implode(' ', [ - Request::get("{$index}-date"), - Request::get("{$index_time}-time") - ])); + $date = Datetime::createFromFormat( + DateTimeInterface::RFC3339_EXTENDED, + Request::get("{$index}-date") + ); + + if (!$date) { + throw new Exception("Date with index '{$index}' could not be parsed"); + } + + $date->setTimezone(new DateTimeZone(date_default_timezone_get())); + $date->setTime( + ...array_map( + intval(...), + explode(':', Request::get("{$index}-time")) + ) + ); + + return $date->getTimestamp(); } private function getUserConfig(): RangeConfig |
