mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-25 07:16:21 +08:00
Improved #79
This commit is contained in:
parent
ae9bb29a47
commit
b4fefc1532
3 changed files with 21 additions and 16 deletions
|
@ -43,7 +43,7 @@ abstract class DateTimeHelper
|
|||
}
|
||||
|
||||
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', $sDateTime));
|
||||
$oDateTime = \DateTime::createFromFormat('D, d M Y H:i:s O', $sDateTime, \MailSo\Base\DateTimeHelper::GetUtcTimeZoneObject());
|
||||
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC822, $sDateTime, static::GetUtcTimeZoneObject());
|
||||
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,10 @@ abstract class DateTimeHelper
|
|||
|
||||
if (\preg_match('/^[a-z]{2,4}, /i', $sDateTime)) // RFC2822 ~ "Thu, 10 Jun 2010 08:58:33 -0700 (PDT)"
|
||||
{
|
||||
return \MailSo\Base\DateTimeHelper::ParseRFC2822DateString($sDateTime);
|
||||
return static::ParseRFC2822DateString($sDateTime);
|
||||
}
|
||||
|
||||
$oDateTime = \DateTime::createFromFormat('d-M-Y H:i:s O', $sDateTime, \MailSo\Base\DateTimeHelper::GetUtcTimeZoneObject());
|
||||
$oDateTime = \DateTime::createFromFormat('d-M-Y H:i:s O', $sDateTime, static::GetUtcTimeZoneObject());
|
||||
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
||||
}
|
||||
|
||||
|
@ -79,20 +79,21 @@ abstract class DateTimeHelper
|
|||
return 0;
|
||||
}
|
||||
|
||||
$oDateTime = \DateTime::createFromFormat('Y-m-d H:i:s O', $sDateTime, \MailSo\Base\DateTimeHelper::GetUtcTimeZoneObject());
|
||||
$oDateTime = \DateTime::createFromFormat('Y-m-d H:i:s O', $sDateTime, static::GetUtcTimeZoneObject());
|
||||
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse date string formated as "2015-05-08T14:32:18.483-07:00"
|
||||
* DateTime::RFC3339_EXTENDED
|
||||
*/
|
||||
public static function TryToParseSpecEtagFormat(string $sDateTime) : int
|
||||
{
|
||||
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', \trim($sDateTime)));
|
||||
$sDateTime = \trim(\preg_replace('/(:[\d]{2})\.[\d]{3}/', '$1', \trim($sDateTime)));
|
||||
$sDateTime = \trim(\preg_replace('/(-[\d]{2})T([\d]{2}:)/', '$1 $2', \trim($sDateTime)));
|
||||
$sDateTime = \trim(\preg_replace('/([\-+][\d]{2}):([\d]{2})$/', ' $1$2', \trim($sDateTime)));
|
||||
$sDateTime = \preg_replace('/ \([a-zA-Z0-9]+\)$/', '', \trim($sDateTime));
|
||||
$sDateTime = \preg_replace('/(:[\d]{2})\.[\d]{3}/', '$1', \trim($sDateTime));
|
||||
$sDateTime = \preg_replace('/(-[\d]{2})T([\d]{2}:)/', '$1 $2', \trim($sDateTime));
|
||||
$sDateTime = \preg_replace('/([\-+][\d]{2}):([\d]{2})$/', ' $1$2', \trim($sDateTime));
|
||||
|
||||
return \MailSo\Base\DateTimeHelper::ParseDateStringType1($sDateTime);
|
||||
return static::ParseDateStringType1($sDateTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ trait CardDAV
|
|||
$this->oLogger->WriteException($oException);
|
||||
}
|
||||
|
||||
/**
|
||||
* find every <response><href>*.vcf</href> with empty <resourcetype/>
|
||||
*/
|
||||
if (\is_array($aResponse))
|
||||
{
|
||||
$mResult = array();
|
||||
|
@ -35,7 +38,6 @@ trait CardDAV
|
|||
$sKey = \rtrim(\trim($sKey), '\\/');
|
||||
if (!empty($sKey) && is_array($aItem))
|
||||
{
|
||||
$aItem = \array_change_key_case($aItem, \CASE_LOWER);
|
||||
if (isset($aItem['{DAV:}getetag']))
|
||||
{
|
||||
$aMatch = array();
|
||||
|
|
|
@ -143,19 +143,21 @@ class Client
|
|||
throw new \InvalidArgumentException('The passed data is not valid XML');
|
||||
}
|
||||
|
||||
$ns = \array_search('urn:DAV', $responseXML->getNamespaces(true));
|
||||
$ns = $ns ? "{$ns}:" : '';
|
||||
$ns = \array_search('urn:DAV', $responseXML->getNamespaces(true)) ?: 'd';
|
||||
// $ns_card = \array_search('urn:ietf:params:xml:ns:carddav', $responseXML->getNamespaces(true));
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($responseXML->xpath("{$ns}response") as $response) {
|
||||
$href = $response->xpath("{$ns}href");
|
||||
$responseXML->registerXPathNamespace($ns, 'urn:DAV');
|
||||
foreach ($responseXML->xpath("{$ns}:response") as $response) {
|
||||
$response->registerXPathNamespace($ns, 'urn:DAV');
|
||||
$href = $response->xpath("{$ns}:href");
|
||||
$href = (string) $href[0];
|
||||
|
||||
$properties = array();
|
||||
foreach ($response->xpath("{$ns}propstat") as $propStat) {
|
||||
$status = $propStat->xpath("{$ns}status");
|
||||
foreach ($response->xpath("{$ns}:propstat") as $propStat) {
|
||||
$propStat->registerXPathNamespace($ns, 'urn:DAV');
|
||||
$status = $propStat->xpath("{$ns}:status");
|
||||
list($httpVersion, $statusCode, $message) = \explode(' ', (string)$status[0], 3);
|
||||
|
||||
$properties[$statusCode] = static::parseProperties(\dom_import_simplexml($propStat));
|
||||
|
|
Loading…
Reference in a new issue