Пример #1
0
 public function testGetValue()
 {
     $_POST['form'] = 'timefield';
     $_POST['time'] = '14:55';
     $this->assertEquals('14:55', $this->txtTime->getValue());
     $_POST['time'] = array('foo', 'bar');
     $this->assertEquals('Array', $this->txtTime->getValue());
 }
Пример #2
0
 /**
  * Get the UTC timestamp for a date/time object combination.
  *
  * @param \SpoonFormDate $date An instance of \SpoonFormDate.
  * @param \SpoonFormTime $time An instance of \SpoonFormTime.
  * @return int
  * @throws \Exception If provided $date, $time or both are invalid
  */
 public static function getUTCTimestamp(\SpoonFormDate $date, \SpoonFormTime $time = null)
 {
     // validate date/time object
     if (!$date->isValid() || $time !== null && !$time->isValid()) {
         throw new \Exception('You need to provide two objects that actually contain valid data.');
     }
     // init vars
     $year = gmdate('Y', $date->getTimestamp());
     $month = gmdate('m', $date->getTimestamp());
     $day = gmdate('j', $date->getTimestamp());
     if ($time !== null) {
         // define hour & minute
         list($hour, $minute) = explode(':', $time->getValue());
     } else {
         // user default time
         $hour = 0;
         $minute = 0;
     }
     // make and return timestamp
     return mktime($hour, $minute, 0, $month, $day, $year);
 }