Checks if the given last day matches the given date.

@param string    $day
@param \DateTime $date

@return Boolean
352721
private function matchesLastDay($day, \DateTime $date)
    {
        $day = substr($day, 0, -1);

        if ($day != $this->getFieldValueFromDate($date)) {
            return false;
        }

        return $this->matchesRelativeDate($date, 'last');
    }
677548
public function seeDateIsWednesday($date) {
        \PHPUnit_Framework_Assert::assertTrue($this->_ParseDate($date)->dayOfWeek == Carbon::WEDNESDAY);
    }
1039505
public function isDayAHoliday(DateTime $dateTime, $region)
    {
        $holidayList = $this->holidayCalculator->calculateHolidaysForYear((int) $dateTime->format('Y'), $region, $dateTime->getTimezone());
        $filteredHolidays = (new IncludeTimespanFilter())->filter($holidayList, [
            IncludeTimespanFilter::PARAM_FIRST_DAY => $dateTime,
            IncludeTimespanFilter::PARAM_LAST_DAY => $dateTime,
        ]);

        return count($filteredHolidays) > 0;
    }
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');
    }
91025
public static function isDate($date = false, $format = 'Y-m-d H:i:s') {

        if($date) {

            $DateTime = DateTime::createFromFormat($format, $date);
            return $DateTime && $DateTime->format($format) == $date;
        }
        
        return false;
    }
1213206
public static boolean isLastDayOfTheMonth(final Date date) {

    Date dateOfMonthsBack = getDateOfMonthsBack(-1, date);
    int dayOfMonth = getDayOfMonth(dateOfMonthsBack);
    Date dateOfDaysBack = getDateOfDaysBack(dayOfMonth, dateOfMonthsBack);
    return dateOfDaysBack.equals(date);
  }
1133940
static public function validate($date)
    {
      // Check if date is a string
      if(is_string($date) && strlen(trim($date)) > 0)
        return false;
        
      // Check if date matches pattern
      if(!preg_match('/^' . self::PATTERN . '$/', $date, $matches))
        return false;
          
      // Extract values from date
      list($original, $year, $month, $day) = $matches;
          
      // Check if all values are valid
      if(!self::validateDate($year, $month, $day))
        return false;
            
      return true;
    }
404444
public static function dateDecDay($date, $day)
    {
        $daystr="-$day day";
        $dateday=date("Y-m-d", strtotime($daystr, strtotime($date)));
        return $dateday;
    }
196676
public static function dateAddDay($date, $day)
    {
        $daystr = "+$day day";
        $dateday = date("Y-m-d", strtotime($daystr, strtotime($date)));
        return $dateday;
    }
646610
protected function isValidDate($date)
    {
        $dt = DateTime::createFromFormat('Y-m-d', $date);

        return ($dt !== false && !array_sum($dt->getLastErrors()));
    }
1269572
public function contains(TimeOfDay $time) : bool
    {
        return $this->start->isEarlierThanOrEqual($time) && $this->end->isLaterThanOrEqual($time);
    }
170727
public function containsDate($date): bool
    {
        $date = Date::castFrom($date);
        if (!$this->start->isBefore($date) && !$this->start->equals($date)) {
            return false;
        }

        if (!$this->end->isAfter($date) && !$this->end->equals($date)) {
            return false;
        }

        return true;
    }
736098
public function matches(\DateTime $date)
    {
        foreach ($this->fields as $field) {
            if (!$field->matches($date)) {
                return false;
            }
        }

        return true;
    }
721224
protected function isNextWeek(DateTime $date)
    {
        $week = new DateTime('+7 days');

        if ($date->getTimestamp() >= time() && $date->getTimestamp() <= $week->getTimestamp()) {
            return true;
        }
        return false;
    }
573870
public function findByDate(\DateTime $date = null)
    {
        $date = $date ?: new \DateTime();

        return $this->repository->findByDate($date);
    }
1113120
def date_matches(self, timestamp):
        """"""
        if self.date is None:
            return False

        timestamp = datetime.fromtimestamp(float(timestamp), self.timezone)
        if self.date.date() == timestamp.date():
            return True

        return False
457031
public function seeDayInWeek($date, $day) {
        \PHPUnit_Framework_Assert::assertEquals($day, $this->_ParseDate($date)->dayOfWeek);
    }