[Pkg-owncloud-commits] [php-sabre-vobject] 25/32: Added getTimeZone to VTIMEZONE components.
David Prévot
taffit at moszumanska.debian.org
Fri Nov 28 22:27:11 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 71ce91ca7879f369979160c713854252711931c0
Author: Evert Pot <me at evertpot.com>
Date: Thu Nov 13 18:04:31 2014 -0500
Added getTimeZone to VTIMEZONE components.
Closes #163
---
ChangeLog.md | 1 +
lib/Component/VTimeZone.php | 16 +++++++++++++++-
tests/VObject/Component/VTimeZoneTest.php | 25 ++++++++++++++++++++++++-
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index 1583252..84ec0ac 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -15,6 +15,7 @@ ChangeLog
floating times or all-day events.
* #159: Master events will no longer get a `RECURRENCE-ID` when expanding.
* #159: `RECURRENCE-ID` for all-day events will now be correct when expanding.
+* #163: Added a `getTimeZone()` method to `VTIMEZONE` components.
3.3.3 (2014-10-09)
diff --git a/lib/Component/VTimeZone.php b/lib/Component/VTimeZone.php
index e1bf5dc..6c3be7b 100644
--- a/lib/Component/VTimeZone.php
+++ b/lib/Component/VTimeZone.php
@@ -17,6 +17,20 @@ use Sabre\VObject;
class VTimeZone extends VObject\Component {
/**
+ * Returns the PHP DateTimeZone for this VTIMEZONE component.
+ *
+ * If we can't accurately determine the timezone, this method will return
+ * UTC.
+ *
+ * @return \DateTimeZone
+ */
+ function getTimeZone() {
+
+ return VObject\TimeZoneUtil::getTimeZone((string)$this->TZID, $this->root);
+
+ }
+
+ /**
* A simple list of validation rules.
*
* This is simply a list of properties, and how many times they either
@@ -30,7 +44,7 @@ class VTimeZone extends VObject\Component {
*
* @var array
*/
- public function getValidationRules() {
+ function getValidationRules() {
return array(
'TZID' => 1,
diff --git a/tests/VObject/Component/VTimeZoneTest.php b/tests/VObject/Component/VTimeZoneTest.php
index 794b221..b2293b3 100644
--- a/tests/VObject/Component/VTimeZoneTest.php
+++ b/tests/VObject/Component/VTimeZoneTest.php
@@ -7,7 +7,7 @@ use Sabre\VObject\Reader;
class VTimeZoneTest extends \PHPUnit_Framework_TestCase {
- public function testValidate() {
+ function testValidate() {
$input = <<<HI
BEGIN:VCALENDAR
@@ -31,4 +31,27 @@ HI;
}
+ function testGetTimeZone() {
+
+ $input = <<<HI
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:YoYo
+BEGIN:VTIMEZONE
+TZID:America/Toronto
+END:VTIMEZONE
+END:VCALENDAR
+HI;
+
+ $obj = Reader::read($input);
+
+ $tz = new \DateTimeZone('America/Toronto');
+
+ $this->assertEquals(
+ $tz,
+ $obj->VTIMEZONE->getDateTimeZone()
+ );
+
+ }
+
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list