Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 59 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <?php
  2.   class My_Validate_Date_LessThan extends My_Validate_Date_Abstract
  3.   {
  4.     const NOT_LESS = 'notLessThan';
  5.  
  6.     /**
  7.      * Sets validator options
  8.      *
  9.      * @param  string|Zend_Date   $date
  10.      * @param  string             $format OPTIONAL
  11.      * @param  string|Zend_Locale $locale OPTIONAL
  12.      * @param  boolean            $orEqual OPTIONAL
  13.      * @return void
  14.      */
  15.     public function __construct($date, $format = null, $locale = null,
  16.         $orEqual = false)
  17.     {
  18.       $this->_messageTemplates[self::NOT_LESS] = "'%value%' is not less than '%date%'";
  19.       parent::__construct($date, $format, $locale, $orEqual);
  20.     }
  21.  
  22.     /**
  23.      * Defined by Zend_Validate_Interface
  24.      *
  25.      * Returns true if $value is a valid date and is greater than the specified
  26.      * $date. If optional $format or $locale is set the date format is checked
  27.      * according to Zend_Date, see Zend_Date::isDate()
  28.      *
  29.      * @param  string|Zend_Date $value
  30.      * @return boolean
  31.      */
  32.     public function isValid($value, $context = null)
  33.     {
  34.       if (!$this->_setValue($value)) return false;
  35.       if (!$this->_parseDate($context)) return false;
  36.  
  37.       $compare = $this->_value->compare($this->_date);
  38.       $compare = ($this->_orEqual) ? ($compare <= 0) : ($compare < 0);
  39.  
  40.       if (!$compare) {
  41.         $this->_error(self::NOT_LESS);
  42.         return false;
  43.       }
  44.  
  45.       return true;
  46.     }
  47.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top