Checks if the given date matches the relative date with the given prefix (ordinal or last).

@param \DateTime $date
@param string    $prefix

@return Boolean
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');
    }
128255
public static boolean isDateInThePast(final Date date)
	{
		boolean inPast = false;
		final Calendar compare = Calendar.getInstance();
		compare.setTime(date);
		final Calendar now = Calendar.getInstance();
		now.setTime(new Date(System.currentTimeMillis()));
		inPast = now.after(compare);
		return inPast;
	}
1349564
public function relativeDate($date)
    {
        $now = new \DateTime();
        $diff = $date->diff($now);
        // natively, diff doesn't contain 'weeks'.
        $diff->w = round($diff->d / 7);
        $message = '';
        foreach (array('y', 'm', 'w', 'd', 'h', 'i', 's') as $part) {
            if ($diff->$part > 0) {
                list($singular, $plural) = self::$RELATIVE_DATE_PART_MAP[$part];
                if ($diff->$part > 1) {
                    $denominator = $plural;
                } else {
                    $denominator = $singular;
                }

                if (null !== $this->translator) {
                    $message = $this->translator->trans(
                        '%count% ' . $denominator . ' ago',
                        array('%count%' => $diff->$part)
                    );
                } else {
                    $message = sprintf('%d %s ago', $diff->$part, $denominator);
                }
                break;
            }
        }

        return $message;
    }
878696
public function is_same($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(); 
  }
664813
public function isWorkDay(\DateTime $date = null): bool
	{
		return Day::isWork($this->configuration->getHolidays(), $date ?: $this);
	}
428829
public function setPattern(
        $prefix    = FilesystemContract::PATTERN_PREFIX,
        $date      = FilesystemContract::PATTERN_DATE,
        $extension = FilesystemContract::PATTERN_EXTENSION
    ) {
        $this->filesystem->setPattern($prefix, $date, $extension);

        return $this;
    }
247102
private function getClosestDateAfter(\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->getClosestOpeningTimeAfter($time, $tmpDate)) {
                $tmpDate->setTime($closestTime->getHours(), $closestTime->getMinutes(), $closestTime->getSeconds());

                return $tmpDate;
            }
        }

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

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

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

        return $tmpDate;
    }
197798
protected function _isExpired($date)
    {
        if ($date) {
            $years = substr($date, 2, 2);
            $month = substr($date, 0, 2);
            $day = date("t", mktime(11, 59, 59, $month, 1, $years));

            $expDate = mktime(23, 59, 59, $month, $day, $years);
            if (time() > $expDate) {
                return true;
            }
        }

        return false;
    }
615545
private function matchesHash($hash, \DateTime $date)
    {
        $ordinals = array(
            '1' => 'first',
            '2' => 'second',
            '3' => 'third',
            '4' => 'fourth',
            '5' => 'fifth'
        );
        $hashParts = explode('#', $hash);

        if ($hashParts[0] != $this->getFieldValueFromDate($date)) {
            return false;
        }

        return $this->matchesRelativeDate($date, $ordinals[$hashParts[1]]);
    }
125262
private function createMonthlyKey($prefix, \DateTime $datetime = null)
    {
        return sprintf("%s_%s", $prefix, $this->formatDate($datetime, 'Y_m'));
    }
1296700
public function is_after($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(); 
  }
636943
public function validateDate($date)
    {
        $subs = null;
        $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs);
        if(!$check1) {
            return false;
        }
        return checkdate($subs[2], $subs[3], $subs[1]);
    }
989375
public function contains(Date $date) : bool
    {
        return $this->start->comesBeforeOrEqual($date) && $this->end->comesAfterOrEqual($date);
    }
710075
public function matches( $prefix ) {

		global $wpdb;

		$prefix = esc_sql( $prefix ) . '%';

		$tables = $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $prefix ) );

		if ( 0 === count( $tables ) ) {
			return true;
		}

		$this->prefixed_tables = $tables;

		return false;
	}
1324273
static function endTimestamp($date = '')
    {
        if (!$dateTime = static::parserDateTime($date)) return false;
        return mktime(23, 59, 59, $dateTime[3], $dateTime[4], $dateTime[5]);
    }
321237
public function compareDate($date = null)
    {
        $start    = $this->createDateUTC($this->toDateString());
        $end      = $this->createDateUTC($date ? $date->toDateString() : date(static::DATE_STR));
        $interval = $end->diff($start);

        return (int)($interval->format('%r') . (bool)$interval->format('%a'));
    }
1101728
public boolean isWithin(Date date) {
		if(first == null) {
			return false;
		} else if(date.equals(first)) {
			return true;
		} else if(date.equals(last)) {
			return true;
		} else if(date.after(first) && date.before(last)) {
			return true;
		} else {
			return false;
		}
	}