From 2467c911bd59f5a369663ca558e1e7721082866d Mon Sep 17 00:00:00 2001 From: Andrii Ilkiv Date: Tue, 5 Nov 2024 13:46:02 +0200 Subject: [PATCH] fix: default timezone for export Signed-off-by: Andrii Ilkiv --- lib/Service/SubmissionService.php | 2 +- tests/Unit/Service/SubmissionServiceTest.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Service/SubmissionService.php b/lib/Service/SubmissionService.php index 8df23779b..42c3bb1ce 100644 --- a/lib/Service/SubmissionService.php +++ b/lib/Service/SubmissionService.php @@ -207,7 +207,7 @@ public function getSubmissionsData(Form $form, string $fileFormat, ?File $file = $submissionEntities = array_reverse($submissionEntities); $questions = $this->questionMapper->findByForm($form->getId()); - $defaultTimeZone = date_default_timezone_get(); + $defaultTimeZone = $this->config->getSystemValueString('default_timezone', 'UTC'); if (!$this->currentUser) { $userTimezone = $this->config->getUserValue($form->getOwnerId(), 'core', 'timezone', $defaultTimeZone); diff --git a/tests/Unit/Service/SubmissionServiceTest.php b/tests/Unit/Service/SubmissionServiceTest.php index 07f71e2a3..55ac37d76 100644 --- a/tests/Unit/Service/SubmissionServiceTest.php +++ b/tests/Unit/Service/SubmissionServiceTest.php @@ -579,7 +579,11 @@ private function setUpCsvTest(array $questions, array $submissions, string $csvT return $questionEntities; })); - date_default_timezone_set('Europe/Berlin'); + $this->config->expects($this->once()) + ->method('getSystemValueString') + ->with('default_timezone', 'UTC') + ->willReturn('Europe/Berlin'); + $this->config->expects($this->once()) ->method('getUserValue') ->with('currentUser', 'core', 'timezone', 'Europe/Berlin')