Ejemplo n.º 1
0
 /**
  * @param int $ownerId
  * @param SeriesUpdateScope|string $scope
  * @param string $title
  * @param DateRange $blackoutDate
  * @param IRepeatOptions $repeatOptions
  * @param int[] $resourceIds
  */
 public function Update($ownerId, $scope, $title, $blackoutDate, $repeatOptions, $resourceIds)
 {
     $this->ownerId = $ownerId;
     $this->title = $title;
     $this->resourceIds = array();
     foreach ($resourceIds as $rid) {
         $this->AddResourceId($rid);
     }
     if ($scope == SeriesUpdateScope::ThisInstance) {
         $this->blackouts = array();
         $this->AddBlackout(new Blackout($blackoutDate));
         $this->SetCurrentBlackout($blackoutDate);
         $this->Repeats(new RepeatNone());
     } else {
         $currentDate = $this->CurrentBlackout()->Date();
         $newDate = $blackoutDate;
         $startDiff = DateDiff::BetweenDates($currentDate->GetBegin(), $newDate->GetBegin());
         $endDiff = DateDiff::BetweenDates($currentDate->GetEnd(), $newDate->GetEnd());
         $earliestDate = $this->GetEarliestDate($blackoutDate);
         if (!$earliestDate->Equals($blackoutDate)) {
             $earliestDate = new DateRange($earliestDate->GetBegin()->ApplyDifference($startDiff), $earliestDate->GetEnd()->ApplyDifference($endDiff));
         }
         $this->blackouts = array();
         $this->AddBlackout(new Blackout($earliestDate));
         $this->SetCurrentBlackout($earliestDate);
         $this->Repeats($repeatOptions);
     }
     $this->isNew = $scope == SeriesUpdateScope::ThisInstance;
 }
 private function GetDateOffsetFromToday($date, $timezone)
 {
     if (empty($date)) {
         return null;
     }
     $today = Date::Create(Date('Y'), Date('m'), Date('d'), 0, 0, 0, $timezone);
     $diff = DateDiff::BetweenDates($today, $date);
     return $diff->Days();
 }
Ejemplo n.º 3
0
 /**
  * @param Date $date
  * @return DateDiff
  */
 public function GetDifference(Date $date)
 {
     return DateDiff::BetweenDates($this, $date);
 }