diff options
Diffstat (limited to '3rdparty/Sabre/VObject/DateTimeParser.php')
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/DateTimeParser.php | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/3rdparty/Sabre/VObject/DateTimeParser.php b/3rdparty/Sabre/VObject/DateTimeParser.php index 23a4bb69916..d09ded96768 100755..100644 --- a/3rdparty/Sabre/VObject/DateTimeParser.php +++ b/3rdparty/Sabre/VObject/DateTimeParser.php @@ -1,18 +1,18 @@ <?php +namespace Sabre\VObject; + /** * DateTimeParser * * This class is responsible for parsing the several different date and time * formats iCalendar and vCards have. * - * @package Sabre - * @subpackage VObject * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class Sabre_VObject_DateTimeParser { +class DateTimeParser { /** * Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object @@ -25,22 +25,22 @@ class Sabre_VObject_DateTimeParser { * @param DateTimeZone $tz * @return DateTime */ - static public function parseDateTime($dt,DateTimeZone $tz = null) { + static public function parseDateTime($dt,\DateTimeZone $tz = null) { // Format is YYYYMMDD + "T" + hhmmss - $result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/',$dt,$matches); + $result = preg_match('/^([1-4][0-9]{3})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/',$dt,$matches); if (!$result) { - throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar datetime value is incorrect: ' . $dt); + throw new \LogicException('The supplied iCalendar datetime value is incorrect: ' . $dt); } if ($matches[7]==='Z' || is_null($tz)) { - $tz = new DateTimeZone('UTC'); + $tz = new \DateTimeZone('UTC'); } - $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] .':' . $matches[6], $tz); + $date = new \DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] .':' . $matches[6], $tz); // Still resetting the timezone, to normalize everything to UTC - $date->setTimeZone(new DateTimeZone('UTC')); + $date->setTimeZone(new \DateTimeZone('UTC')); return $date; } @@ -54,13 +54,13 @@ class Sabre_VObject_DateTimeParser { static public function parseDate($date) { // Format is YYYYMMDD - $result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches); + $result = preg_match('/^([1-4][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches); if (!$result) { - throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar date value is incorrect: ' . $date); + throw new \LogicException('The supplied iCalendar date value is incorrect: ' . $date); } - $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new DateTimeZone('UTC')); + $date = new \DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new \DateTimeZone('UTC')); return $date; } @@ -79,7 +79,7 @@ class Sabre_VObject_DateTimeParser { $result = preg_match('/^(?P<plusminus>\+|-)?P((?P<week>\d+)W)?((?P<day>\d+)D)?(T((?P<hour>\d+)H)?((?P<minute>\d+)M)?((?P<second>\d+)S)?)?$/', $duration, $matches); if (!$result) { - throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar duration value is incorrect: ' . $duration); + throw new \LogicException('The supplied iCalendar duration value is incorrect: ' . $duration); } if (!$asString) { @@ -128,7 +128,7 @@ class Sabre_VObject_DateTimeParser { if ($duration==='P') { $duration = 'PT0S'; } - $iv = new DateInterval($duration); + $iv = new \DateInterval($duration); if ($invert) $iv->invert = true; return $iv; |