Explorar o código

Add support for time strings without seconds.

Brian Kendig %!s(int64=11) %!d(string=hai) anos
pai
achega
c7a5cf6dcd
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      library/Zend/Date.php

+ 12 - 0
library/Zend/Date.php

@@ -2067,9 +2067,18 @@ class Zend_Date extends Zend_Date_DateObject
                 }
                 // (T)hh:mm:ss
                 preg_match('/[T,\s]{0,1}(\d{2}):(\d{2}):(\d{2})/', $tmpdate, $timematch);
+                // (T)hhmmss
                 if (empty($timematch)) {
                     preg_match('/[T,\s]{0,1}(\d{2})(\d{2})(\d{2})/', $tmpdate, $timematch);
                 }
+                // (T)hh:mm
+                if (empty($timematch)) {
+                    preg_match('/[T,\s]{0,1}(\d{2}):(\d{2})/', $tmpdate, $timematch);
+                }
+                // (T)hhmm
+                if (empty($timematch)) {
+                    preg_match('/[T,\s]{0,1}(\d{2})(\d{2})/', $tmpdate, $timematch);
+                }
                 if (empty($datematch) and empty($timematch)) {
                     require_once 'Zend/Date/Exception.php';
                     throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
@@ -2093,6 +2102,9 @@ class Zend_Date extends Zend_Date_DateObject
                     $timematch[2] = 0;
                     $timematch[3] = 0;
                 }
+                if (!isset($timematch[3])) {
+                    $timematch[3] = 0;
+                }
 
                 if (($calc == 'set') || ($calc == 'cmp')) {
                     --$datematch[2];