summaryrefslogtreecommitdiff
path: root/inc/IXR_Library.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-06-09 21:43:10 +0200
committerAndreas Gohr <andi@splitbrain.org>2010-06-09 21:43:10 +0200
commit5ab78106b0f9170d5e4930d0901862e4373a686f (patch)
tree1bf04d874dd0afd853c33bb70c0178d3b9697d5b /inc/IXR_Library.php
parentccee78424602b02309b2c81b3fa932bbcce1a03b (diff)
downloadrpg-5ab78106b0f9170d5e4930d0901862e4373a686f.tar.gz
rpg-5ab78106b0f9170d5e4930d0901862e4373a686f.tar.bz2
Make XMLRPC date parsing more flexible FS#1966
Since the specs aren't 100% clear, dates might be passed in different formats by various XMLRPC clients. This patch makes date parsing a bit more flexible. Unit tests included.
Diffstat (limited to 'inc/IXR_Library.php')
-rw-r--r--inc/IXR_Library.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/inc/IXR_Library.php b/inc/IXR_Library.php
index b82952d74..2fb7dfe68 100644
--- a/inc/IXR_Library.php
+++ b/inc/IXR_Library.php
@@ -615,12 +615,14 @@ class IXR_Date {
$this->second = gmdate('s', $timestamp);
}
function parseIso($iso) {
- $this->year = substr($iso, 0, 4);
- $this->month = substr($iso, 5, 2);
- $this->day = substr($iso, 8, 2);
- $this->hour = substr($iso, 11, 2);
- $this->minute = substr($iso, 14, 2);
- $this->second = substr($iso, 17, 2);
+ if(preg_match('/^(\d\d\d\d)-?(\d\d)-?(\d\d)([T ](\d\d):(\d\d)(:(\d\d))?)?/',$iso,$match)){
+ $this->year = (int) $match[1];
+ $this->month = (int) $match[2];
+ $this->day = (int) $match[3];
+ $this->hour = (int) $match[5];
+ $this->minute = (int) $match[6];
+ $this->second = (int) $match[8];
+ }
}
function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;