Skip to content

Commit

Permalink
fix endTime
Browse files Browse the repository at this point in the history
  • Loading branch information
michb committed Jan 25, 2024
1 parent 041ce26 commit 8540224
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Import/CalendarEventsImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,26 @@ private function importEvent( array $new, CalendarModel $calendar ): ?int {

$endDate = new Date(strtotime($new['endDate']));
$event->endDate = $endDate->dayBegin;
$event->endTime = $event->endDate;

if( $event->startDate === $event->endDate ) {
$event->endDate = null;
$event->endTime = $event->startDate;
}

$event->addTime = $new['allDay'] ? '' : '1';
if( $event->addTime ) {

$event->startTime = strtotime($new['startDate']);
$event->endTime = $event->startTime;
$event->endTime = strtotime(date('Y-m-d', $event->endDate ?? $event->startDate). ' ' .date('H:i:s',$event->startTime));

if( $new['showEndtime'] ) {
$event->endTime = strtotime($new['endDate']);
}

} else {

if( (strlen($event->endDate) && $event->endTime == $event->endTime) || $event->startTime == $event->endTime ) {
if( (strlen($event->endDate) && $event->endDate == $event->endTime) || $event->startTime == $event->endTime ) {
$event->endTime = (strtotime('+ 1 day', $event->endTime) - 1);
}
}
Expand Down

0 comments on commit 8540224

Please sign in to comment.