Determines if a date is past

@param  Carobon|String|Integer $date
@return boolean
510929
public static function isExpired($date = null)
    {
        return (bool) self::parse($date)->lte(Carbon::now());
    }
1338813
private static function cast(Date $date = null)
	{
		if (!is_null($date))
		{
			$date = new DateTime($date);
		}

		return $date;
	}
1075940
public function toDate($date)
	{
		$this->current = (is_string($date) ? new \DateTime($date, self::$utc) : $date);
	}
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;
    }
352721
private function matchesLastDay($day, \DateTime $date)
    {
        $day = substr($day, 0, -1);

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

        return $this->matchesRelativeDate($date, 'last');
    }
856667
public boolean checkDate(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);

		Calendar minCal = Calendar.getInstance();
		minCal.setTime(minSelectableDate);
		minCal.set(Calendar.HOUR_OF_DAY, 0);
		minCal.set(Calendar.MINUTE, 0);
		minCal.set(Calendar.SECOND, 0);
		minCal.set(Calendar.MILLISECOND, 0);

		Calendar maxCal = Calendar.getInstance();
		maxCal.setTime(maxSelectableDate);
		maxCal.set(Calendar.HOUR_OF_DAY, 0);
		maxCal.set(Calendar.MINUTE, 0);
		maxCal.set(Calendar.SECOND, 0);
		maxCal.set(Calendar.MILLISECOND, 0);

		return !(calendar.before(minCal) || calendar.after(maxCal));
	}
162904
public static function isValid($date)
	{
		if(self::validateXSDDateTimeFormat($date) && self::validateXSDDateTimeValue($date))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
136814
public static function timeAgo($date)
    {
        $timeSince = false;
        if ( ! empty($date))
        {
            $ago = date('U') - $date;
            $periods = [__('second'), __('minute'), __('hour'), __('day'), __('week'), __('month'), __('year'), __('ten year')];
            $lengths = ['60', '60', '24', '7', '4.35', '12', '10'];
            for ($j = 0; $ago >= $lengths[$j]; $j++)
            {
                $ago /= $lengths[$j];
            }
            $ago = round($ago);

            if ($ago != 1)
            {
                $periods[$j] .= __('s');
            }
            $timeSince = $ago . ' ' . $periods[$j] . __(' ago');
        }

        return $timeSince;
    }
818137
public function getUserDate($date)
    {
        $date = DBDatetime::create()->setValue($date);
        $member = Security::getCurrentUser();
        return $date->FormatFromSettings($member);
    }
121689
public function hasStatementForDate($date)
    {
        if (is_string($date)) {
            $date = new \DateTime($date);
        }

        return null !== $this->getStatementForDate($date);
    }
750558
private function checkDateIsValid($date, $canBeNull = false)
    {
        if ($date === null
            && $canBeNull
        ) {
            return;
        }

        Date::factory($date);
    }
1286015
public function usedVATOnDate($date)
    {
        $period = $this->getPeriod($date);

        return !is_null($period) && !empty($period->getStandardRate());
    }
273103
public static function date2sql($date)
    {
        $dt = new Datetime();
        
        return ($dt->set_date($date)) ? $dt->toSql() : false;
    }
216466
protected function resolveCarbon($date = null)
    {
        if (!$date) {
            return $this->nowWithSameTz();
        }

        if (is_string($date)) {
            return static::parse($date, $this->getTimezone());
        }

        static::expectDateTime($date, ['null', 'string']);

        return $date instanceof self ? $date : static::instance($date);
    }
563795
public function parse($date) {
        if(is_int($date) || is_double($date) || (is_string($date) && preg_match('@^[0-9]+$@', $date))) {
            return (double)$date;
        } elseif($date instanceof Date) {
            return $date->getEpoch();
        } elseif(is_null($date)) {
            return false;
        } else {
            $date = trim(Assert::isString($date));
        }
        $date = $this->parseHoursMinutes($date);
        if(preg_match('@^[0-9]+$@', $date)) {
            return (int)$date;
        }
        $date = $this->stripTimezone($date);
        $date = $this->stripRange($date);

        if(preg_match('@^(\d{4}-\d{2}-\d{2} )?24:00(:00)?$@', trim($date), $matches)) {
            if(isset($matches[1]) && strlen($matches[1]) > 0) {
                $date = strtotime($matches[1]);
            } else {
                $date = time();
            }
            return mktime(0, 0, 0, date('n', $date), date('j', $date) + 1, date('Y', $date));

        }
        //change a/p to am/pm
        $date = preg_replace('@(^|[^a-z])(a|p)([^a-z]|$)@i', '\\1\\2m\\3', $date);
        //Add a colon from 315am,1215 am
        $date = preg_replace('@(^|[^0-9])(\d{1,2})(\d{2})\s*(am|pm)@i', '\\1\\2:\\3\\4', $date);

        //Fix for dashes instead of slashes
        $date = preg_replace('@(\d{2})-(\d{2})-(\d{4})@', '\\1/\\2/\\3', $date);
        //Fix for dots instead of slashes
        $date = preg_replace('@(\d{2})\.(\d{2})\.(\d{4})@', '\\1/\\2/\\3', $date);

        //Fix for UK/euro Version
        if(in_array(Formatter::getDefault()->getDateFormat(), array(Formatter::DATE_FORMAT_UK, Formatter::DATE_FORMAT_EURO))) {
            //Switch the d/m/Y to the US format m/d/Y to be able to parse
            $date = preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\\2/\\1/\\3', $date);
        }
        switch(strtolower($date)) {
            case '9999-12-31':
                return 253402232400;
                break;
            case '0000-00-00':
                return 0;
                break;
            case '0000-00-00 00:00:00':
                return 0;
                break;
            case '24:00:00':
            case '24:00':
                return mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
                break;
            case 'thanksgiving':
                $firstDay = mktime(0, 0, 0, 11, 1);
                $add = 26 - date('w', $firstDay);
                if($add < 22) {
                    $add += 7;
                }
                return mktime(0, 0, 0, 11, $add);
                break;
            default:
                return strtotime($date);
        }
    }
883212
public function on($date)
    {
        $parsedDate = \date_parse($date);
        $segments = \array_intersect_key($parsedDate, $this->fieldsPosition);

        if ($parsedDate['year']) {
            $this->skip(static function () use ($parsedDate) {
                return (int) \date('Y') !== $parsedDate['year'];
            });
        }

        foreach ($segments as $key => $value) {
            if (false !== $value) {
                $this->spliceIntoPosition($this->fieldsPosition[$key], (string) $value);
            }
        }

        return $this;
    }
131716
public static function textDate($date)
    {
        $date = Helper::date("U", $date);

        $diff = Helper::dateDiff($date, time());

        $text = "";

        # If the difference is less than 1 full day then claim it was today
        if ($diff < 1) {
            $text .= "Today";

        # If it's more than 1 day, but less then 2 then claim it was yesterday
        } elseif ($diff < 2) {
            $text .= "Yesterday";

        # If was over a month ago then display a date
        } elseif ($diff > 30) {
            $text .= date("D jS M", $date);
            $year = date("Y", $date);
            if ($year < date("Y")) {
                $text.= " " . $year;
            }

        # Otherwise display how many days ago it was
        } else {
            $text .= $diff . " days ago";
        }

        $text .= " at " . date("g:ia", $date);

        return $text;
    }