[Pkg-owncloud-commits] [php-sabre-vobject] 10/19: Fix Property\VCard\Date to serialize DateTime objects as date-only strings (#217)
David Prévot
taffit at moszumanska.debian.org
Tue May 19 20:10:13 UTC 2015
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 75dac1e9ab18c28536a72c9b75fb5314d9b576c9
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Thu Apr 2 18:22:00 2015 +0200
Fix Property\VCard\Date to serialize DateTime objects as date-only strings (#217)
---
lib/Property/VCard/Date.php | 12 ++++++++++++
tests/VObject/Property/VCard/DateAndOrTimeTest.php | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/lib/Property/VCard/Date.php b/lib/Property/VCard/Date.php
index 7b44d05..328c9ba 100644
--- a/lib/Property/VCard/Date.php
+++ b/lib/Property/VCard/Date.php
@@ -30,4 +30,16 @@ class Date extends DateAndOrTime {
}
+ /**
+ * Sets the property as a DateTime object.
+ *
+ * @param \DateTime $dt
+ * @return void
+ */
+ public function setDateTime(\DateTime $dt) {
+
+ $this->value = $dt->format('Ymd');
+
+ }
+
}
diff --git a/tests/VObject/Property/VCard/DateAndOrTimeTest.php b/tests/VObject/Property/VCard/DateAndOrTimeTest.php
index e27d8c1..0f9a32c 100644
--- a/tests/VObject/Property/VCard/DateAndOrTimeTest.php
+++ b/tests/VObject/Property/VCard/DateAndOrTimeTest.php
@@ -162,6 +162,18 @@ class DateAndOrTimeTest extends \PHPUnit_Framework_TestCase {
}
+ public function testGetDate() {
+
+ $datetime = new \DateTime('2014-04-02');
+
+ $vcard = new VObject\Component\VCard();
+ $prop = $vcard->createProperty('BDAY', $datetime, null, 'DATE');
+
+ $this->assertEquals('DATE', $prop->getValueType());
+ $this->assertEquals('BDAY:20140402', rtrim($prop->serialize()));
+
+ }
+
public function testGetDateIncomplete() {
$datetime = '--0407';
--
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