]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Move Temporal::convert() to DateTimeFormat::convert()
[friendica.git] / src / Protocol / DFRN.php
index 871358d988bcc572a9d87740843e3a93103e6cae..2269bffcfdc49db18de53961044f2f88a9dbe701 100644 (file)
@@ -26,8 +26,8 @@ use Friendica\Model\User;
 use Friendica\Object\Image;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\Crypto;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use Friendica\Content\Text\BBCode;
 
@@ -229,7 +229,7 @@ class DFRN
                        }
                }
 
-               $check_date = Temporal::convert($last_update);
+               $check_date = DateTimeFormat::utc($last_update);
 
                $r = q(
                        "SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -421,7 +421,7 @@ class DFRN
 
                XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
                XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
-               XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', ATOM_TIME));
+               XML::addElement($doc, $mail, "dfrn:sentdate", DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
                XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
                XML::addElement($doc, $mail, "dfrn:content", $item['body']);
 
@@ -587,7 +587,7 @@ class DFRN
 
                /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
 
-               XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
 
                $author = self::addAuthor($doc, $owner, $authorelement, $public);
                $root->appendChild($author);
@@ -622,9 +622,9 @@ class DFRN
 
                $author = $doc->createElement($authorelement);
 
-               $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
-               $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
-               $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
+               $namdate = DateTimeFormat::utc($owner['name-date'].'+00:00', DateTimeFormat::ATOM);
+               $uridate = DateTimeFormat::utc($owner['uri-date'].'+00:00', DateTimeFormat::ATOM);
+               $picdate = DateTimeFormat::utc($owner['avatar-date'].'+00:00', DateTimeFormat::ATOM);
 
                $attributes = [];
 
@@ -903,7 +903,7 @@ class DFRN
                }
 
                if ($item['deleted']) {
-                       $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)];
+                       $attributes = ["ref" => $item['uri'], "when" => DateTimeFormat::utc($item['edited'] . '+00:00', DateTimeFormat::ATOM)];
                        return XML::createElement($doc, "at:deleted-entry", "", $attributes);
                }
 
@@ -983,8 +983,8 @@ class DFRN
                XML::addElement($doc, $entry, "id", $item["uri"]);
                XML::addElement($doc, $entry, "title", $item["title"]);
 
-               XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", ATOM_TIME));
-               XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", ATOM_TIME));
+               XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"] . "+00:00", DateTimeFormat::ATOM));
+               XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"] . "+00:00", DateTimeFormat::ATOM));
 
                // "dfrn:env" is used to read the content
                XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
@@ -1388,7 +1388,7 @@ class DFRN
                        "SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
                        intval($contact["uid"]),
                        intval($contact["id"]),
-                       dbesc(Temporal::convert($birthday)),
+                       dbesc(DateTimeFormat::utc($birthday)),
                        dbesc("birthday")
                );
 
@@ -1406,10 +1406,10 @@ class DFRN
                        VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
                        intval($contact["uid"]),
                        intval($contact["id"]),
-                       dbesc(Temporal::convert()),
-                       dbesc(Temporal::convert()),
-                       dbesc(Temporal::convert($birthday)),
-                       dbesc(Temporal::convert($birthday . " + 1 day ")),
+                       dbesc(DateTimeFormat::utcNow()),
+                       dbesc(DateTimeFormat::utcNow()),
+                       dbesc(DateTimeFormat::utc($birthday)),
+                       dbesc(DateTimeFormat::utc($birthday . " + 1 day ")),
                        dbesc($bdtext),
                        dbesc($bdtext2),
                        dbesc("birthday")
@@ -1889,7 +1889,7 @@ class DFRN
                        intval($suggest["cid"]),
                        dbesc($suggest["body"]),
                        dbesc($hash),
-                       dbesc(Temporal::convert()),
+                       dbesc(DateTimeFormat::utcNow()),
                        intval(0)
                );
 
@@ -2081,13 +2081,13 @@ class DFRN
 
                if (self::isEditedTimestampNewer($current, $item)) {
                        // do not accept (ignore) an earlier edit than one we currently have.
-                       if (Temporal::convert($item["edited"]) < $current["edited"]) {
+                       if (DateTimeFormat::utc($item["edited"]) < $current["edited"]) {
                                return false;
                        }
 
                        $fields = ['title' => $item["title"], 'body' => $item["body"],
-                                       'tag' => $item["tag"], 'changed' => Temporal::convert(),
-                                       'edited' => Temporal::convert($item["edited"])];
+                                       'tag' => $item["tag"], 'changed' => DateTimeFormat::utcNow(),
+                                       'edited' => DateTimeFormat::utc($item["edited"])];
 
                        $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
                        dba::update('item', $fields, $condition);
@@ -2422,7 +2422,7 @@ class DFRN
 
                // Is there an existing item?
                if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
-                       && (Temporal::convert($item["edited"]) < $current[0]["edited"])
+                       && (DateTimeFormat::utc($item["edited"]) < $current[0]["edited"])
                ) {
                        logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
                        return;
@@ -2753,9 +2753,9 @@ class DFRN
                        }
                }
                if ($when) {
-                       $when = Temporal::convert($when);
+                       $when = DateTimeFormat::utc($when);
                } else {
-                       $when = Temporal::convert("now");
+                       $when = DateTimeFormat::utcNow();
                }
 
                if (!$uri || !$importer["id"]) {
@@ -2836,7 +2836,7 @@ class DFRN
                                                `body` = '', `title` = ''
                                        WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
                                        dbesc($when),
-                                       dbesc(Temporal::convert()),
+                                       dbesc(DateTimeFormat::utcNow()),
                                        dbesc($uri),
                                        intval($importer["uid"])
                                );
@@ -2849,7 +2849,7 @@ class DFRN
                                                `body` = '', `title` = ''
                                        WHERE `uri` = '%s' AND `uid` IN (0, %d)",
                                        dbesc($when),
-                                       dbesc(Temporal::convert()),
+                                       dbesc(DateTimeFormat::utcNow()),
                                        dbesc($uri),
                                        intval($importer["uid"])
                                );
@@ -3157,8 +3157,8 @@ class DFRN
                        return false;
                }
 
-               $existing_edited = Temporal::convert($existing['edited']);
-               $update_edited = Temporal::convert($update['edited']);
+               $existing_edited = DateTimeFormat::utc($existing['edited']);
+               $update_edited = DateTimeFormat::utc($update['edited']);
 
                return (strcmp($existing_edited, $update_edited) < 0);
        }