Checks if our event ends after the date supplied
@param \DateTime $date
@return bool
962046
public function endsLater(\DateTime $date) {
    $later = FALSE;

    $t2 = $this->end_date->getTimeStamp();

    $t4 = $date->getTimestamp();

    if ($t2 > $t4) {
      $later = TRUE;
    }

    return $later;
  }
42844
private function between(\DateTime $time, DateTimeFormatInterface $start, DateTimeFormatInterface $end)
    {
        return $this->after($time, $start) && $this->before($time, $end);
    }
510929
public static function isExpired($date = null)
    {
        return (bool) self::parse($date)->lte(Carbon::now());
    }
814188
public function is_before($date)
  {
    //check if the argument $date is an instance of this class
    if ( $date instanceof $this){
      $tmp = $date;
    }
    else {
      $tmp = new \bbn\time($date);
    }
    return $this->get_time() < $tmp->get_time(); 
  }
736098
public function matches(\DateTime $date)
    {
        foreach ($this->fields as $field) {
            if (!$field->matches($date)) {
                return false;
            }
        }

        return true;
    }
43605
public static function inBetween( $startDate, $endDate, $date ) {

		$start 	= is_string( $startDate ) ? strtotime( $startDate ) : $startDate->getTimestamp();
		$end 	= is_string( $endDate ) ? strtotime( $endDate ) : $endDate->getTimestamp();
		$test 	= is_string( $date ) ? strtotime( $date ) : $date->getTimestamp();

		// Test in between start and end
		return ( ( $test >= $start ) && ( $test <= $end ) );
	}
762983
public function contains(DateTime $dateTime) : bool
    {
        return $this->start->comesBeforeOrEqual($dateTime) && $this->end->comesAfterOrEqual($dateTime);
    }
493489
private function matchesRelativeDate(\DateTime $date, $prefix)
    {
        $correctDate = new \DateTime($prefix . ' ' . $date->format('D') . ' of ' . $date->format('F') . ' ' . $date->format('Y'));

        return $date->format('Y-m-d') == $correctDate->format('Y-m-d');
    }
1043190
public function dateIsLater(\DateTime $date) {
    $dateLater = FALSE;

    $t2 = $this->end_date->getTimeStamp();

    $t4 = $date->getTimestamp();

    if ($t2 < $t4) {
      $dateLater = TRUE;
    }

    return $dateLater;
  }
980064
public function setDateEnd( $date )
	{
		if ( $date == $this->getDateEnd() ) { return; }

		$this->_checkDateFormat($date);

		$this->_values['end'] = ( $date !== null ? (string) $date : null );

		$this->setModified();
	}
484436
protected function eventHasBeenFinished(Node $node) {
    // Use the start date when the end date is not set to determine if the
    // event is closed.
    /** @var \Drupal\Core\Datetime\DrupalDateTime $check_end_date */
    $check_end_date = $node->field_event_date->date;

    if (isset($node->field_event_date_end->date)) {
      $check_end_date = $node->field_event_date_end->date;
    }

    $current_time = new DrupalDateTime();

    // The event has finished if the end date is smaller than the current date.
    if ($current_time > $check_end_date) {
      return TRUE;
    }
    return FALSE;
  }
646610
protected function isValidDate($date)
    {
        $dt = DateTime::createFromFormat('Y-m-d', $date);

        return ($dt !== false && !array_sum($dt->getLastErrors()));
    }
523832
protected function isTomorrow(DateTime $date)
    {
        $tomorrow = new DateTime('+1 day');
        $start = new DateTime($tomorrow->format('Y-m-d') . ' 00:00:00');
        $end   = new DateTime($tomorrow->format('Y-m-d') . ' 23:59:59');

        if ($date->getTimestamp() >= $start->getTimestamp() && $date->getTimestamp() <= $end->getTimestamp()) {
            return true;
        }
        return false;
    }
522279
private function getClosestDateBefore(\DateTime $date)
    {
        $tmpDate = clone $date;
        $dayOfWeek = (int) $tmpDate->format('N');
        $time = Time::fromDate($tmpDate);

        if (!$this->holidays->isHoliday($tmpDate) && null !== $day = $this->getDay($dayOfWeek)) {
            if (null !== $closestTime = $day->getClosestOpeningTimeBefore($time, $tmpDate)) {
                $tmpDate->setTime($closestTime->getHours(), $closestTime->getMinutes(), $closestTime->getSeconds());

                return $tmpDate;
            }
        }

        $tmpDate = $this->getDateBefore($tmpDate);

        while ($this->holidays->isHoliday($tmpDate)) {
            $tmpDate = $this->getDateBefore($tmpDate);
        }

        $closestDay = $this->getClosestDayBefore((int) $tmpDate->format('N'));
        $closingTime = $closestDay->getClosingTime($tmpDate);
        $tmpDate->setTime($closingTime->getHours(), $closingTime->getMinutes(), $closingTime->getSeconds());

        return $tmpDate;
    }
170882
public function setEndDate($date)
    {
        $date = AnDomainAttributeDate::getInstance()->setDate($date);
        $this->set('endDate', $date);

        return $this;
    }
217985
public function startsEarlier(\DateTime $date) {
    $earlier = FALSE;

    $t1 = $this->start_date->getTimeStamp();

    $t3 = $date->getTimestamp();

    if ($t1 < $t3) {
      $earlier = TRUE;
    }

    return $earlier;
  }
1081439
private function getDateAfter(\DateTime $date)
    {
        $tmpDate = clone $date;
        $tmpDate->modify('+1 day');

        $dayOfWeek = (int) $tmpDate->format('N');
        $closestDay = $this->getClosestDayAfter($dayOfWeek);

        if ($closestDay->getDayOfWeek() !== $dayOfWeek) {
            $tmpDate->modify(sprintf('next %s', Days::toString($closestDay->getDayOfWeek())));
        }

        return $tmpDate;
    }