/**
  * @static
  * @param Sabre\VObject\Component\VEvent $component
  * @return int
  */
 public static function getDtEndTimeStamp(&$component)
 {
     /** @var Sabre\VObject\Property\DateTime $dtstart */
     $dtstart = $component->__get("DTSTART");
     if ($component->__get("DTEND")) {
         /** @var Sabre\VObject\Property\DateTime $dtend */
         $dtend = $component->__get("DTEND");
         return $dtend->getDateTime()->getTimeStamp();
     } elseif ($component->__get("DURATION")) {
         $endDate = clone $dtstart->getDateTime();
         $endDate->add(Sabre\VObject\DateTimeParser::parse($component->__get("DURATION")->value));
         return $endDate->getTimeStamp();
     } elseif ($dtstart->getDateType() === Sabre\VObject\Property\DateTime::DATE) {
         $endDate = clone $dtstart->getDateTime();
         $endDate->modify('+1 day');
         return $endDate->getTimeStamp();
     } else {
         return $dtstart->getDateTime()->getTimeStamp() + 3600;
     }
 }
Example #2
0
 public function getEventDates($component)
 {
     $allday = 0;
     $endField = $this->getEndFieldName($component->name);
     // Start
     if (isset($component->DTSTART)) {
         $DTSTART = Sabre\VObject\DateTimeParser::parse($component->DTSTART);
         $date_start = $DTSTART->format('Y-m-d');
         $time_start = $DTSTART->format('H:i:s');
         $startHasTime = $component->DTSTART->hasTime();
     } else {
         $DTSTAMP = Sabre\VObject\DateTimeParser::parse($component->DTSTAMP);
         $date_start = $DTSTAMP->format('Y-m-d');
         $time_start = $DTSTAMP->format('H:i:s');
     }
     //End
     if (isset($component->{$endField})) {
         $DTEND = Sabre\VObject\DateTimeParser::parse($component->{$endField});
         $endHasTime = $component->{$endField}->hasTime();
         if (!$endHasTime) {
             $DTEND->modify('-1 day');
         }
         $due_date = $DTEND->format('Y-m-d');
         $time_end = $DTEND->format('H:i:s');
     } else {
         $endTime = strtotime('+7 day', strtotime($date_start . ' ' . $time_start));
         $due_date = date('Y-m-d', $endTime);
         $time_end = date('H:i:s', $endTime);
     }
     if (!$startHasTime && !$endHasTime) {
         $allday = 1;
     }
     return ['allday' => $allday, 'date_start' => $date_start, 'due_date' => $due_date, 'time_start' => $time_start, 'time_end' => $time_end];
 }