. */ /** * Doctrine_Validator_Past * * @package Doctrine * @subpackage Validator * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ * @author Roman Borschel */ class Doctrine_Validator_Past { /** * checks if the given value is a valid date in the past. * * @param mixed $value * @return boolean */ public function validate($value) { if ($value === null) { return true; } $e = explode('-', $value); if (count($e) !== 3) { return false; } if (is_array($this->args) && isset($this->args['timezone'])) { switch (strtolower($this->args['timezone'])) { case 'gmt': $now = gmdate("U") - date("Z"); break; default: $now = getdate(); break; } } else { $now = getdate(); } if ($now['year'] < $e[0]) { return false; } else if ($now['year'] == $e[0]) { if ($now['mon'] < $e[1]) { return false; } else if ($now['mon'] == $e[1]) { return $now['mday'] > $e[2]; } else { return true; } } else { return true; } } }