Skip to content

Commit

Permalink
Add support for time strings without seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkendig-disney committed Oct 29, 2014
1 parent 4a9d203 commit c7a5cf6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/Zend/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -2067,9 +2067,18 @@ private function _calculate($calc, $date, $part, $locale)
}
// (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);
Expand All @@ -2093,6 +2102,9 @@ private function _calculate($calc, $date, $part, $locale)
$timematch[2] = 0;
$timematch[3] = 0;
}
if (!isset($timematch[3])) {
$timematch[3] = 0;
}

if (($calc == 'set') || ($calc == 'cmp')) {
--$datematch[2];
Expand Down

0 comments on commit c7a5cf6

Please sign in to comment.