diff --git a/lib/ext/Syncroton/Model/AXMLEntry.php b/lib/ext/Syncroton/Model/AXMLEntry.php --- a/lib/ext/Syncroton/Model/AXMLEntry.php +++ b/lib/ext/Syncroton/Model/AXMLEntry.php @@ -222,6 +222,31 @@ return $dirty; } + /** + * Fix date-time string input + * + * @param string $date Date time string + * + * @return string + */ + protected function _fixDateTimeString($date) + { + // Note: Some clients send date-time in local charset instead of ascii + // It is not supported by PHP DateTime constructor + + $from = [ + '١','٢','٣','٤','٥','٦','٧','٨','٩','٠', // arabic + '۱','۲','۳','۴','۵','۶','۷','۸','۹','۰', // persian + ]; + + $to = [ + '1','2','3','4','5','6','7','8','9','0', + '1','2','3','4','5','6','7','8','9','0', + ]; + + return str_replace($from, $to, $date); + } + /** * * @param string $element @@ -284,7 +309,7 @@ break; case 'datetime': - $property = new DateTime((string) $xmlElement, new DateTimeZone('UTC')); + $property = new DateTime($this->_fixDateTimeString((string) $xmlElement), new DateTimeZone('UTC')); break; case 'number':