From 94940be02c74028946eb9c58d83905a6755fd49b Mon Sep 17 00:00:00 2001 From: Constantin Graf Date: Thu, 6 Jun 2024 18:35:19 +0200 Subject: [PATCH] Fixed timezone in time entries importer --- app/Service/Import/Importers/ClockifyTimeEntriesImporter.php | 4 ++-- app/Service/Import/Importers/TogglTimeEntriesImporter.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php b/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php index c2fc256f..3be945e9 100644 --- a/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php +++ b/app/Service/Import/Importers/ClockifyTimeEntriesImporter.php @@ -121,7 +121,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter if ($start === null) { throw new ImportException('Start date ("'.$record['Start Date'].'") or time ("'.$record['Start Time'].'") are invalid'); } - $timeEntry->start = $start; + $timeEntry->start = $start->utc(); // End try { @@ -136,7 +136,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter if ($end === null) { throw new ImportException('End date ("'.$record['End Date'].'") or time ("'.$record['End Time'].'") are invalid'); } - $timeEntry->end = $end; + $timeEntry->end = $end->utc(); $timeEntry->setComputedAttributeValue('billable_rate'); $timeEntry->save(); $this->timeEntriesCreated++; diff --git a/app/Service/Import/Importers/TogglTimeEntriesImporter.php b/app/Service/Import/Importers/TogglTimeEntriesImporter.php index 859dde45..c5d6a7cf 100644 --- a/app/Service/Import/Importers/TogglTimeEntriesImporter.php +++ b/app/Service/Import/Importers/TogglTimeEntriesImporter.php @@ -112,7 +112,7 @@ class TogglTimeEntriesImporter extends DefaultImporter if ($start === null) { throw new ImportException('Start date ("'.$record['Start date'].'") or time ("'.$record['Start time'].'") are invalid'); } - $timeEntry->start = $start; + $timeEntry->start = $start->utc(); try { $end = Carbon::createFromFormat('Y-m-d H:i:s', $record['End date'].' '.$record['End time'], $timezone); @@ -122,7 +122,7 @@ class TogglTimeEntriesImporter extends DefaultImporter if ($end === null) { throw new ImportException('End date ("'.$record['End date'].'") or time ("'.$record['End time'].'") are invalid'); } - $timeEntry->end = $end; + $timeEntry->end = $end->utc(); $timeEntry->setComputedAttributeValue('billable_rate'); $timeEntry->save(); $this->timeEntriesCreated++;