mirror of
https://github.com/friendica/friendica
synced 2025-04-28 12:24:23 +02:00
Refactor datetime_convert into Temporal::convert
- Changed parameter order to save space - Refactor select_timezone into Temporal::getTimezoneSelect - Refactor field_timezone into Temporal::getTimezoneField
This commit is contained in:
parent
d478ef6c6d
commit
dc366bf1f7
62 changed files with 512 additions and 432 deletions
|
@ -27,6 +27,7 @@ use Friendica\Object\Image;
|
|||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
|
||||
|
@ -228,7 +229,7 @@ class DFRN
|
|||
}
|
||||
}
|
||||
|
||||
$check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
|
||||
$check_date = Temporal::convert($last_update);
|
||||
|
||||
$r = q(
|
||||
"SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
|
@ -420,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", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', ATOM_TIME));
|
||||
XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', ATOM_TIME));
|
||||
XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
|
||||
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
|
||||
|
||||
|
@ -586,7 +587,7 @@ class DFRN
|
|||
|
||||
/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
|
||||
|
||||
XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
|
||||
XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
|
||||
|
||||
$author = self::addAuthor($doc, $owner, $authorelement, $public);
|
||||
$root->appendChild($author);
|
||||
|
@ -621,9 +622,9 @@ class DFRN
|
|||
|
||||
$author = $doc->createElement($authorelement);
|
||||
|
||||
$namdate = datetime_convert('UTC', 'UTC', $owner['name-date'].'+00:00', ATOM_TIME);
|
||||
$uridate = datetime_convert('UTC', 'UTC', $owner['uri-date'].'+00:00', ATOM_TIME);
|
||||
$picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
|
||||
$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);
|
||||
|
||||
$attributes = [];
|
||||
|
||||
|
@ -902,7 +903,7 @@ class DFRN
|
|||
}
|
||||
|
||||
if ($item['deleted']) {
|
||||
$attributes = ["ref" => $item['uri'], "when" => datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME)];
|
||||
$attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)];
|
||||
return XML::createElement($doc, "at:deleted-entry", "", $attributes);
|
||||
}
|
||||
|
||||
|
@ -982,8 +983,8 @@ class DFRN
|
|||
XML::addElement($doc, $entry, "id", $item["uri"]);
|
||||
XML::addElement($doc, $entry, "title", $item["title"]);
|
||||
|
||||
XML::addElement($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"] . "+00:00", ATOM_TIME));
|
||||
XML::addElement($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"] . "+00:00", ATOM_TIME));
|
||||
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));
|
||||
|
||||
// "dfrn:env" is used to read the content
|
||||
XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
|
||||
|
@ -1387,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(datetime_convert("UTC", "UTC", $birthday)),
|
||||
dbesc(Temporal::convert($birthday)),
|
||||
dbesc("birthday")
|
||||
);
|
||||
|
||||
|
@ -1405,10 +1406,10 @@ class DFRN
|
|||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
|
||||
intval($contact["uid"]),
|
||||
intval($contact["id"]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert("UTC", "UTC", $birthday)),
|
||||
dbesc(datetime_convert("UTC", "UTC", $birthday . " + 1 day ")),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc(Temporal::convert($birthday)),
|
||||
dbesc(Temporal::convert($birthday . " + 1 day ")),
|
||||
dbesc($bdtext),
|
||||
dbesc($bdtext2),
|
||||
dbesc("birthday")
|
||||
|
@ -1888,7 +1889,7 @@ class DFRN
|
|||
intval($suggest["cid"]),
|
||||
dbesc($suggest["body"]),
|
||||
dbesc($hash),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
intval(0)
|
||||
);
|
||||
|
||||
|
@ -2080,13 +2081,13 @@ class DFRN
|
|||
|
||||
if (self::isEditedTimestampNewer($current, $item)) {
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if (datetime_convert("UTC", "UTC", $item["edited"]) < $current["edited"]) {
|
||||
if (Temporal::convert($item["edited"]) < $current["edited"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = ['title' => $item["title"], 'body' => $item["body"],
|
||||
'tag' => $item["tag"], 'changed' => datetime_convert(),
|
||||
'edited' => datetime_convert("UTC", "UTC", $item["edited"])];
|
||||
'tag' => $item["tag"], 'changed' => Temporal::convert(),
|
||||
'edited' => Temporal::convert($item["edited"])];
|
||||
|
||||
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
|
||||
dba::update('item', $fields, $condition);
|
||||
|
@ -2421,7 +2422,7 @@ class DFRN
|
|||
|
||||
// Is there an existing item?
|
||||
if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
|
||||
&& (datetime_convert("UTC", "UTC", $item["edited"]) < $current[0]["edited"])
|
||||
&& (Temporal::convert($item["edited"]) < $current[0]["edited"])
|
||||
) {
|
||||
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
|
||||
return;
|
||||
|
@ -2752,9 +2753,9 @@ class DFRN
|
|||
}
|
||||
}
|
||||
if ($when) {
|
||||
$when = datetime_convert("UTC", "UTC", $when, "Y-m-d H:i:s");
|
||||
$when = Temporal::convert($when);
|
||||
} else {
|
||||
$when = datetime_convert("UTC", "UTC", "now", "Y-m-d H:i:s");
|
||||
$when = Temporal::convert("now");
|
||||
}
|
||||
|
||||
if (!$uri || !$importer["id"]) {
|
||||
|
@ -2835,7 +2836,7 @@ class DFRN
|
|||
`body` = '', `title` = ''
|
||||
WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
|
||||
dbesc($when),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc($uri),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
|
@ -2848,7 +2849,7 @@ class DFRN
|
|||
`body` = '', `title` = ''
|
||||
WHERE `uri` = '%s' AND `uid` IN (0, %d)",
|
||||
dbesc($when),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc($uri),
|
||||
intval($importer["uid"])
|
||||
);
|
||||
|
@ -3156,8 +3157,8 @@ class DFRN
|
|||
return false;
|
||||
}
|
||||
|
||||
$existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
|
||||
$update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
|
||||
$existing_edited = Temporal::convert($existing['edited']);
|
||||
$update_edited = Temporal::convert($update['edited']);
|
||||
|
||||
return (strcmp($existing_edited, $update_edited) < 0);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class Diaspora
|
|||
$r = q(
|
||||
"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`)
|
||||
VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
|
||||
datetime_convert(),
|
||||
Temporal::convert(),
|
||||
dbesc($addr),
|
||||
dbesc($addr),
|
||||
dbesc($server),
|
||||
|
@ -84,9 +84,9 @@ class Diaspora
|
|||
dbesc($batch),
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval(CONTACT_IS_FOLLOWER),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert())
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc(Temporal::convert())
|
||||
);
|
||||
|
||||
$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
|
||||
|
@ -870,7 +870,7 @@ class Diaspora
|
|||
dbesc($arr["confirm"]),
|
||||
dbesc($arr["alias"]),
|
||||
dbesc($arr["pubkey"]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc($arr["url"]),
|
||||
dbesc($arr["network"])
|
||||
);
|
||||
|
@ -893,7 +893,7 @@ class Diaspora
|
|||
dbesc($arr["network"]),
|
||||
dbesc($arr["alias"]),
|
||||
dbesc($arr["pubkey"]),
|
||||
dbesc(datetime_convert())
|
||||
dbesc(Temporal::convert())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1653,9 +1653,9 @@ class Diaspora
|
|||
$text = unxmlify($data->text);
|
||||
|
||||
if (isset($data->created_at)) {
|
||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
|
||||
} else {
|
||||
$created_at = datetime_convert();
|
||||
$created_at = Temporal::convert();
|
||||
}
|
||||
|
||||
if (isset($data->thread_parent_guid)) {
|
||||
|
@ -1785,7 +1785,7 @@ class Diaspora
|
|||
$msg_guid = notags(unxmlify($mesg->guid));
|
||||
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
|
||||
$msg_text = unxmlify($mesg->text);
|
||||
$msg_created_at = datetime_convert("UTC", "UTC", notags(unxmlify($mesg->created_at)));
|
||||
$msg_created_at = Temporal::convert(notags(unxmlify($mesg->created_at)));
|
||||
|
||||
if ($msg_conversation_guid != $guid) {
|
||||
logger("message conversation guid does not belong to the current conversation.");
|
||||
|
@ -1830,7 +1830,7 @@ class Diaspora
|
|||
|
||||
dba::unlock();
|
||||
|
||||
dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
|
||||
dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
|
||||
|
||||
notification(
|
||||
[
|
||||
|
@ -1864,7 +1864,7 @@ class Diaspora
|
|||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$subject = notags(unxmlify($data->subject));
|
||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
|
||||
$participants = notags(unxmlify($data->participants));
|
||||
|
||||
$messages = $data->message;
|
||||
|
@ -1896,7 +1896,7 @@ class Diaspora
|
|||
dbesc($guid),
|
||||
dbesc($author),
|
||||
dbesc($created_at),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc($subject),
|
||||
dbesc($participants)
|
||||
);
|
||||
|
@ -2097,7 +2097,7 @@ class Diaspora
|
|||
$guid = notags(unxmlify($data->guid));
|
||||
$conversation_guid = notags(unxmlify($data->conversation_guid));
|
||||
$text = unxmlify($data->text);
|
||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
|
||||
|
||||
$contact = self::allowedContactByHandle($importer, $author, true);
|
||||
if (!$contact) {
|
||||
|
@ -2163,7 +2163,7 @@ class Diaspora
|
|||
|
||||
dba::unlock();
|
||||
|
||||
dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
|
||||
dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2314,7 +2314,7 @@ class Diaspora
|
|||
$birthday = str_replace("1000", "1901", $birthday);
|
||||
|
||||
if ($birthday != "") {
|
||||
$birthday = datetime_convert("UTC", "UTC", $birthday, "Y-m-d");
|
||||
$birthday = Temporal::convert($birthday, "UTC", "UTC", "Y-m-d");
|
||||
}
|
||||
|
||||
// this is to prevent multiple birthday notifications in a single year
|
||||
|
@ -2330,7 +2330,7 @@ class Diaspora
|
|||
dbesc($name),
|
||||
dbesc($nick),
|
||||
dbesc($author),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc($birthday),
|
||||
dbesc($location),
|
||||
dbesc($about),
|
||||
|
@ -2536,7 +2536,7 @@ class Diaspora
|
|||
intval($importer["uid"]),
|
||||
dbesc($ret["network"]),
|
||||
dbesc($ret["addr"]),
|
||||
datetime_convert(),
|
||||
Temporal::convert(),
|
||||
dbesc($ret["url"]),
|
||||
dbesc(normalise_link($ret["url"])),
|
||||
dbesc($batch),
|
||||
|
@ -2579,7 +2579,7 @@ class Diaspora
|
|||
0,
|
||||
dbesc(L10n::t("Sharing notification from Diaspora network")),
|
||||
dbesc($hash),
|
||||
dbesc(datetime_convert())
|
||||
dbesc(Temporal::convert())
|
||||
);
|
||||
} else {
|
||||
// automatic friend approval
|
||||
|
@ -2610,8 +2610,8 @@ class Diaspora
|
|||
WHERE `id` = %d
|
||||
",
|
||||
intval($new_relation),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
dbesc(Temporal::convert()),
|
||||
intval($contact_record["id"])
|
||||
);
|
||||
|
||||
|
@ -2715,7 +2715,7 @@ class Diaspora
|
|||
{
|
||||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
|
||||
$root_author = notags(unxmlify($data->root_author));
|
||||
$root_guid = notags(unxmlify($data->root_guid));
|
||||
/// @todo handle unprocessed property "provider_display_name"
|
||||
|
@ -2851,8 +2851,8 @@ class Diaspora
|
|||
'deleted' => true,
|
||||
'title' => '',
|
||||
'body' => '',
|
||||
'edited' => datetime_convert(),
|
||||
'changed' => datetime_convert()],
|
||||
'edited' => Temporal::convert(),
|
||||
'changed' => Temporal::convert()],
|
||||
['id' => $item["id"]]
|
||||
);
|
||||
|
||||
|
@ -2929,7 +2929,7 @@ class Diaspora
|
|||
{
|
||||
$author = notags(unxmlify($data->author));
|
||||
$guid = notags(unxmlify($data->guid));
|
||||
$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
|
||||
$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
|
||||
$public = notags(unxmlify($data->public));
|
||||
$text = unxmlify($data->text);
|
||||
$provider_display_name = notags(unxmlify($data->provider_display_name));
|
||||
|
@ -3606,10 +3606,10 @@ class Diaspora
|
|||
}
|
||||
|
||||
if ($event['start']) {
|
||||
$eventdata['start'] = datetime_convert($eventdata['timezone'], "UTC", $event['start'], $mask);
|
||||
$eventdata['start'] = Temporal::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
|
||||
}
|
||||
if ($event['finish'] && !$event['nofinish']) {
|
||||
$eventdata['end'] = datetime_convert($eventdata['timezone'], "UTC", $event['finish'], $mask);
|
||||
$eventdata['end'] = Temporal::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
|
||||
}
|
||||
if ($event['summary']) {
|
||||
$eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary']));
|
||||
|
@ -3651,7 +3651,7 @@ class Diaspora
|
|||
|
||||
$public = (($item["private"]) ? "false" : "true");
|
||||
|
||||
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
|
||||
$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
|
||||
|
||||
// Detect a share element and do a reshare
|
||||
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
|
||||
|
@ -3854,7 +3854,7 @@ class Diaspora
|
|||
$parent = $p[0];
|
||||
|
||||
$text = html_entity_decode(bb2diaspora($item["body"]));
|
||||
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
|
||||
$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
|
||||
|
||||
$comment = ["author" => self::myHandle($owner),
|
||||
"guid" => $item["guid"],
|
||||
|
@ -4085,12 +4085,12 @@ class Diaspora
|
|||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
|
||||
"created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
|
||||
"participants" => $cnv["recips"]
|
||||
];
|
||||
|
||||
$body = bb2diaspora($item["body"]);
|
||||
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
|
||||
$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
|
||||
|
||||
$msg = [
|
||||
"author" => $myaddr,
|
||||
|
@ -4108,7 +4108,7 @@ class Diaspora
|
|||
"author" => $cnv["creator"],
|
||||
"guid" => $cnv["guid"],
|
||||
"subject" => $cnv["subject"],
|
||||
"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
|
||||
"created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
|
||||
"participants" => $cnv["recips"],
|
||||
"message" => $msg];
|
||||
|
||||
|
@ -4216,7 +4216,7 @@ class Diaspora
|
|||
if ($year < 1004) {
|
||||
$year = 1004;
|
||||
}
|
||||
$dob = datetime_convert('UTC', 'UTC', $year . '-' . $month . '-'. $day, 'Y-m-d');
|
||||
$dob = Temporal::convert($year . '-' . $month . '-'. $day, 'UTC', 'UTC', 'Y-m-d');
|
||||
}
|
||||
|
||||
$about = $profile['about'];
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
namespace Friendica\Protocol;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
|
@ -12,13 +11,14 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\GContact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\Lock;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\XML;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
|
@ -199,7 +199,7 @@ class OStatus
|
|||
$contact["location"] = $value;
|
||||
}
|
||||
|
||||
$contact['name-date'] = datetime_convert();
|
||||
$contact['name-date'] = Temporal::convert();
|
||||
|
||||
dba::update('contact', $contact, ['id' => $contact["id"]], $current);
|
||||
|
||||
|
@ -220,7 +220,7 @@ class OStatus
|
|||
'nurl' => normalise_link($author["author-link"]),
|
||||
'nick' => $contact["nick"], 'alias' => $contact["alias"],
|
||||
'about' => $contact["about"], 'location' => $contact["location"],
|
||||
'success_update' => datetime_convert(), 'last-update' => datetime_convert()];
|
||||
'success_update' => Temporal::convert(), 'last-update' => Temporal::convert()];
|
||||
|
||||
dba::update('contact', $fields, ['id' => $cid], $old_contact);
|
||||
|
||||
|
@ -558,7 +558,7 @@ class OStatus
|
|||
dba::update(
|
||||
'item',
|
||||
['deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => datetime_convert(), 'changed' => datetime_convert()],
|
||||
'edited' => Temporal::convert(), 'changed' => Temporal::convert()],
|
||||
['id' => $deleted["id"]]
|
||||
);
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ class OStatus
|
|||
XML::addElement($doc, $root, "title", $title);
|
||||
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
|
||||
XML::addElement($doc, $root, "logo", $owner["photo"]);
|
||||
XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
|
||||
XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
|
||||
|
||||
$author = self::addAuthor($doc, $owner);
|
||||
$root->appendChild($author);
|
||||
|
@ -1539,7 +1539,7 @@ class OStatus
|
|||
XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
|
||||
XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
|
||||
XML::addElement($doc, $source, "icon", $contact["photo"]);
|
||||
XML::addElement($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
|
||||
XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", ATOM_TIME));
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
@ -1923,8 +1923,8 @@ class OStatus
|
|||
|
||||
XML::addElement($doc, $entry, "activity:verb", $verb);
|
||||
|
||||
XML::addElement($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"]."+00:00", ATOM_TIME));
|
||||
XML::addElement($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"]."+00:00", ATOM_TIME));
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2127,7 +2127,7 @@ class OStatus
|
|||
$last_update = 'now -30 days';
|
||||
}
|
||||
|
||||
$check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
|
||||
$check_date = Temporal::convert($last_update);
|
||||
$authorid = Contact::getIdForURL($owner["url"], 0);
|
||||
|
||||
$sql_extra = '';
|
||||
|
|
|
@ -16,6 +16,7 @@ use Friendica\Model\GContact;
|
|||
use Friendica\Model\Profile;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Temporal;
|
||||
use dba;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
|
@ -314,7 +315,7 @@ class PortableContact
|
|||
$contact = ["url" => $profile];
|
||||
|
||||
if ($gcontacts[0]["created"] <= NULL_DATE) {
|
||||
$contact['created'] = datetime_convert();
|
||||
$contact['created'] = Temporal::convert();
|
||||
}
|
||||
|
||||
if ($force) {
|
||||
|
@ -337,7 +338,7 @@ class PortableContact
|
|||
if ($server_url != "") {
|
||||
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
|
||||
if ($force) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
}
|
||||
|
||||
|
@ -411,14 +412,14 @@ class PortableContact
|
|||
|
||||
// Set the date of the last contact
|
||||
/// @todo By now the function "update_gcontact" doesn't work with this field
|
||||
//$contact["last_contact"] = datetime_convert();
|
||||
//$contact["last_contact"] = Temporal::convert();
|
||||
|
||||
$contact = array_merge($contact, $noscrape);
|
||||
|
||||
GContact::update($contact);
|
||||
|
||||
if (trim($noscrape["updated"]) != "") {
|
||||
$fields = ['last_contact' => datetime_convert()];
|
||||
$fields = ['last_contact' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
|
||||
|
@ -467,7 +468,7 @@ class PortableContact
|
|||
}
|
||||
|
||||
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
|
||||
|
@ -483,7 +484,7 @@ class PortableContact
|
|||
$feedret = Network::curl($data["poll"]);
|
||||
|
||||
if (!$feedret["success"]) {
|
||||
$fields = ['last_failure' => datetime_convert()];
|
||||
$fields = ['last_failure' => Temporal::convert()];
|
||||
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
|
||||
|
||||
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
|
||||
|
@ -532,7 +533,7 @@ class PortableContact
|
|||
|
||||
public static function updateNeeded($created, $updated, $last_failure, $last_contact)
|
||||
{
|
||||
$now = strtotime(datetime_convert());
|
||||
$now = strtotime(Temporal::convert());
|
||||
|
||||
if ($updated > $last_contact) {
|
||||
$contact_time = strtotime($updated);
|
||||
|
@ -921,7 +922,7 @@ class PortableContact
|
|||
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
|
||||
if (DBM::is_result($gserver)) {
|
||||
if ($gserver["created"] <= NULL_DATE) {
|
||||
$fields = ['created' => datetime_convert()];
|
||||
$fields = ['created' => Temporal::convert()];
|
||||
$condition = ['nurl' => normalise_link($server_url)];
|
||||
dba::update('gserver', $fields, $condition);
|
||||
}
|
||||
|
@ -968,7 +969,7 @@ class PortableContact
|
|||
// Mastodon uses the "@" for user profiles.
|
||||
// But this can be misunderstood.
|
||||
if (parse_url($server_url, PHP_URL_USER) != '') {
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -984,7 +985,7 @@ class PortableContact
|
|||
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
|
||||
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -999,7 +1000,7 @@ class PortableContact
|
|||
// Quit if there is a timeout
|
||||
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
|
||||
dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
|
||||
dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1331,9 +1332,9 @@ class PortableContact
|
|||
|
||||
if ($failure) {
|
||||
$last_contact = $orig_last_contact;
|
||||
$last_failure = datetime_convert();
|
||||
$last_failure = Temporal::convert();
|
||||
} else {
|
||||
$last_contact = datetime_convert();
|
||||
$last_contact = Temporal::convert();
|
||||
$last_failure = $orig_last_failure;
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1362,7 @@ class PortableContact
|
|||
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
|
||||
} elseif (!$failure) {
|
||||
$fields['nurl'] = normalise_link($server_url);
|
||||
$fields['created'] = datetime_convert();
|
||||
$fields['created'] = Temporal::convert();
|
||||
dba::insert('gserver', $fields);
|
||||
}
|
||||
logger("End discovery for server " . $server_url, LOGGER_DEBUG);
|
||||
|
@ -1525,7 +1526,7 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return true;
|
||||
|
@ -1534,7 +1535,7 @@ class PortableContact
|
|||
self::checkServer($server["url"], $server["network"], true);
|
||||
|
||||
// If we couldn't reach the server, we will try it some time later
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
|
||||
return false;
|
||||
|
@ -1560,7 +1561,7 @@ class PortableContact
|
|||
foreach ($r as $server) {
|
||||
if (!self::checkServer($server["url"], $server["network"])) {
|
||||
// The server is not reachable? Okay, then we will try it later
|
||||
$fields = ['last_poco_query' => datetime_convert()];
|
||||
$fields = ['last_poco_query' => Temporal::convert()];
|
||||
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue