function is_valid($value) { assert('is_string($value)'); $pattern = '/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/'; if (!preg_match($pattern, $value, $matches)) { return false; } return AnewtDateTime::is_valid_date_ymd($matches[1], $matches[2], $matches[3]); }
/** * Checks if a given date is valid. * * \param $date * Any date-like object; this could be a string, timestamp or * a AnewtDateTimeAtom instance. * * \return * True if this is a valid date, false otherwise. */ static function is_valid($date) { assert('$date instanceof AnewtDateTimeAtom;'); return AnewtDateTime::is_valid_date_ymd(AnewtDateTime::year($date), AnewtDateTime::month($date), AnewtDateTime::day($date)) && AnewtDateTime::is_valid_time_hms(AnewtDateTime::hour($date), AnewtDateTime::minute($date), AnewtDateTime::second($date)); }