[Pkg-owncloud-commits] [php-sabre-vobject] 146/341: jCal and jCard UTC-OFFSET are not well formed.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:42 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 730addf0793b2a8fa80c3cd6dd5e192637a8addd
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Fri Jan 16 11:59:28 2015 +0100
jCal and jCard UTC-OFFSET are not well formed.
According to http://tools.ietf.org/html/rfc5545#section-3.6.5,
UTC-OFFSET must be formatted `+0500` and not `+05:00`.
Fix #186.
---
lib/Property/UtcOffset.php | 25 ++++++++++++++++++++++---
tests/VObject/JCalTest.php | 2 +-
tests/VObject/JCardTest.php | 2 +-
tests/VObject/Parser/JsonTest.php | 4 ++--
4 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/lib/Property/UtcOffset.php b/lib/Property/UtcOffset.php
index e08e595..a2be6a0 100644
--- a/lib/Property/UtcOffset.php
+++ b/lib/Property/UtcOffset.php
@@ -36,14 +36,14 @@ class UtcOffset extends Text {
}
/**
- * Sets the XML value, as it would appear in a xCard or xCal object.
+ * Sets the JSON value, as it would appear in a jCard or jCal object.
*
* The value must always be an array.
*
* @param array $value
* @return void
*/
- function setXmlValue(array $value) {
+ function setJsonValue(array $value) {
$value = array_map(
function($value) {
@@ -51,7 +51,26 @@ class UtcOffset extends Text {
},
$value
);
- parent::setXmlValue($value);
+ parent::setJsonValue($value);
+
+ }
+
+ /**
+ * Returns the value, in the format it should be encoded for JSON.
+ *
+ * This method must always return an array.
+ *
+ * @return array
+ */
+ function getJsonValue() {
+
+ return array_map(
+ function($value) {
+ return substr($value, 0, -2) . ':' .
+ substr($value, -2);
+ },
+ parent::getJsonValue()
+ );
}
}
diff --git a/tests/VObject/JCalTest.php b/tests/VObject/JCalTest.php
index f23165b..7a041c5 100644
--- a/tests/VObject/JCalTest.php
+++ b/tests/VObject/JCalTest.php
@@ -20,7 +20,7 @@ class JCalTest extends \PHPUnit_Framework_TestCase {
"SEQUENCE" => 5,
"FREEBUSY" => array("20130526T210213Z/PT1H", "20130626T120000Z/20130626T130000Z"),
"URL" => "http://example.org/",
- "TZOFFSETFROM" => "+05:00",
+ "TZOFFSETFROM" => "+0500",
"RRULE" => array('FREQ' => 'WEEKLY', 'BYDAY' => array('MO','TU')),
));
diff --git a/tests/VObject/JCardTest.php b/tests/VObject/JCardTest.php
index 9bd0f9a..0a2e977 100644
--- a/tests/VObject/JCardTest.php
+++ b/tests/VObject/JCardTest.php
@@ -40,7 +40,7 @@ class JCardTest extends \PHPUnit_Framework_TestCase {
$card->add('X-KARMA-POINTS', '42', array('VALUE' => 'INTEGER'));
$card->add('X-GRADE', '1.3', array('VALUE' => 'FLOAT'));
- $card->add('TZ', '-05:00', array('VALUE' => 'UTC-OFFSET'));
+ $card->add('TZ', '-0500', array('VALUE' => 'UTC-OFFSET'));
$expected = array(
"vcard",
diff --git a/tests/VObject/Parser/JsonTest.php b/tests/VObject/Parser/JsonTest.php
index 23b7f9a..a4d27b3 100644
--- a/tests/VObject/Parser/JsonTest.php
+++ b/tests/VObject/Parser/JsonTest.php
@@ -183,7 +183,7 @@ X-TIME-REDUCED;VALUE=TIME:23
X-TIME-TRUNCATED;VALUE=TIME:--30
X-KARMA-POINTS;VALUE=INTEGER:42
X-GRADE;VALUE=FLOAT:1.3
-TZ;VALUE=UTC-OFFSET:-05:00
+TZ;VALUE=UTC-OFFSET:-0500
END:VCARD
VCF;
@@ -330,7 +330,7 @@ GEO:51.96668;7.61876
SEQUENCE:5
FREEBUSY:20130526T210213/PT1H,20130626T120000/20130626T130000
URL:http://example.org/
-TZOFFSETFROM:+05:00
+TZOFFSETFROM:+0500
RRULE:FREQ=WEEKLY;BYDAY=MO,TU
X-BOOL;VALUE=BOOLEAN:TRUE
X-TIME;VALUE=TIME:08:00:00
--
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