mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Fix datetime parser for #79
This commit is contained in:
parent
14c8e81332
commit
a407986483
2 changed files with 7 additions and 3 deletions
|
|
@ -43,7 +43,8 @@ abstract class DateTimeHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', $sDateTime));
|
$sDateTime = \trim(\preg_replace('/ \([a-zA-Z0-9]+\)$/', '', $sDateTime));
|
||||||
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC822, $sDateTime, static::GetUtcTimeZoneObject());
|
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC822, $sDateTime, static::GetUtcTimeZoneObject())
|
||||||
|
?: \DateTime::createFromFormat('D, d M Y H:i:s O', $sDateTime, static::GetUtcTimeZoneObject());
|
||||||
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
return $oDateTime ? $oDateTime->getTimestamp() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,10 +86,14 @@ abstract class DateTimeHelper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse date string formated as "2015-05-08T14:32:18.483-07:00"
|
* Parse date string formated as "2015-05-08T14:32:18.483-07:00"
|
||||||
* DateTime::RFC3339_EXTENDED
|
|
||||||
*/
|
*/
|
||||||
public static function TryToParseSpecEtagFormat(string $sDateTime) : int
|
public static function TryToParseSpecEtagFormat(string $sDateTime) : int
|
||||||
{
|
{
|
||||||
|
$oDateTime = \DateTime::createFromFormat(\DateTime::RFC3339_EXTENDED, $sDateTime, static::GetUtcTimeZoneObject());
|
||||||
|
if ($oDateTime) {
|
||||||
|
return $oDateTime->getTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
$sDateTime = \preg_replace('/ \([a-zA-Z0-9]+\)$/', '', \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})\.[\d]{3}/', '$1', \trim($sDateTime));
|
||||||
$sDateTime = \preg_replace('/(-[\d]{2})T([\d]{2}:)/', '$1 $2', \trim($sDateTime));
|
$sDateTime = \preg_replace('/(-[\d]{2})T([\d]{2}:)/', '$1 $2', \trim($sDateTime));
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,6 @@ class Client
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$propList[$propertyName] = (string) $element;
|
$propList[$propertyName] = (string) $element;
|
||||||
// $propList[$propertyName] = \dom_import_simplexml($element)->textContent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue