Exemple #1
0
 /**
  * Adds the ability to pass in an array with key names of variable
  *	  length but a minimum of 3 characters, upper or lower case.
  * Requires one object, one associative array, or 3 integer parameters.
  *
  * @param object|array|int $hou
  * @param int $min
  * @param int $sec
  */
 public function setTime($hou, $min = 0, $sec = 0)
 {
     switch (gettype($hou)) {
         case 'object':
             $hou = (array) $hou;
         case 'array':
             //	change all keys to lower case
             $arrIn = array_change_key_case($hou);
             //	get current values as input can be incomplete
             $hou = $this->format('G');
             $min = $this->format('i');
             $sec = $this->format('s');
             foreach ($arrIn as $k => $v) {
                 switch (substr($k, 0, 3)) {
                     case 'hou':
                         $hou = $v;
                         break;
                     case 'min':
                         $min = $v;
                         break;
                     case 'sec':
                         $sec = $v;
                         break;
                 }
             }
     }
     parent::setTime((int) $hou, (int) $min, (int) $sec);
     return $this;
 }
Exemple #2
0
 /**
  * Subtracts DateInterval from stored date and
  *	   sets time to 6am to avoid possible Daylight Savings transition issues.
  *
  * @param DateInterval $interval
  * @return Date
  */
 public function sub($interval)
 {
     parent::sub($interval);
     parent::setTime(12, 0, 0);
     return $this;
 }