Move Temporal::convert() to DateTimeFormat::convert()

This commit is contained in:
Hypolite Petovan 2018-01-26 21:38:34 -05:00
parent b7a7355292
commit 5e7285b9ba
64 changed files with 568 additions and 551 deletions

View file

@ -20,8 +20,8 @@ use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
require_once 'boot.php';
@ -112,7 +112,7 @@ class Contact extends BaseObject
$return = dba::insert('contact', [
'uid' => $user['uid'],
'created' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(),
'self' => 1,
'name' => $user['username'],
'nick' => $user['nickname'],
@ -129,9 +129,9 @@ class Contact extends BaseObject
'poll' => System::baseUrl() . '/dfrn_poll/' . $user['nickname'],
'confirm' => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
'poco' => System::baseUrl() . '/poco/' . $user['nickname'],
'name-date' => Temporal::utcNow(),
'uri-date' => Temporal::utcNow(),
'avatar-date' => Temporal::utcNow(),
'name-date' => DateTimeFormat::utcNow(),
'uri-date' => DateTimeFormat::utcNow(),
'avatar-date' => DateTimeFormat::utcNow(),
'closeness' => 0
]);
@ -210,10 +210,10 @@ class Contact extends BaseObject
}
if ($contact['term-date'] <= NULL_DATE) {
dba::update('contact', ['term-date' => Temporal::utcNow()], ['id' => $contact['id']]);
dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
if ($contact['url'] != '') {
dba::update('contact', ['term-date' => Temporal::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
}
} else {
/* @todo
@ -224,7 +224,7 @@ class Contact extends BaseObject
/// @todo Check for contact vitality via probing
$expiry = $contact['term-date'] . ' + 32 days ';
if (Temporal::utcNow() > Temporal::utc($expiry)) {
if (DateTimeFormat::utcNow() > DateTimeFormat::utc($expiry)) {
/* Relationship is really truly dead. archive them rather than
* delete, though if the owner tries to unarchive them we'll start
* the whole process over again.
@ -688,7 +688,7 @@ class Contact extends BaseObject
$contact_id = $contact["id"];
// Update the contact every 7 days
$update_contact = ($contact['avatar-date'] < Temporal::utc('now -7 days'));
$update_contact = ($contact['avatar-date'] < DateTimeFormat::utc('now -7 days'));
// We force the update if the avatar is empty
if (!x($contact, 'avatar')) {
@ -728,7 +728,7 @@ class Contact extends BaseObject
if (!$contact_id) {
dba::insert('contact', [
'uid' => $uid,
'created' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(),
'url' => $data["url"],
'nurl' => normalise_link($data["url"]),
'addr' => $data["addr"],
@ -749,9 +749,9 @@ class Contact extends BaseObject
'request' => $data["request"],
'confirm' => $data["confirm"],
'poco' => $data["poco"],
'name-date' => Temporal::utcNow(),
'uri-date' => Temporal::utcNow(),
'avatar-date' => Temporal::utcNow(),
'name-date' => DateTimeFormat::utcNow(),
'uri-date' => DateTimeFormat::utcNow(),
'avatar-date' => DateTimeFormat::utcNow(),
'writable' => 1,
'blocked' => 0,
'readonly' => 0,
@ -823,13 +823,13 @@ class Contact extends BaseObject
}
if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) {
$updated['uri-date'] = Temporal::utcNow();
$updated['uri-date'] = DateTimeFormat::utcNow();
}
if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) {
$updated['name-date'] = Temporal::utcNow();
$updated['name-date'] = DateTimeFormat::utcNow();
}
$updated['avatar-date'] = Temporal::utcNow();
$updated['avatar-date'] = DateTimeFormat::utcNow();
dba::update('contact', $updated, ['id' => $contact_id], $contact);
@ -1026,7 +1026,7 @@ class Contact extends BaseObject
if ($photos) {
dba::update(
'contact',
['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::utcNow()],
['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()],
['id' => $cid]
);
@ -1261,7 +1261,7 @@ class Contact extends BaseObject
// create contact record
dba::insert('contact', [
'uid' => $uid,
'created' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(),
'url' => $ret['url'],
'nurl' => normalise_link($ret['url']),
'addr' => $ret['addr'],
@ -1485,7 +1485,7 @@ class Contact extends BaseObject
foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);
$nextbd = Temporal::utcNow('Y') . substr($rr['bd'], 4);
$nextbd = DateTimeFormat::utcNow('Y') . substr($rr['bd'], 4);
/*
* Add new birthday event for this person
@ -1497,7 +1497,7 @@ class Contact extends BaseObject
// Check for duplicates
$s = q("SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
intval($rr['uid']), intval($rr['id']), dbesc(Temporal::utc($nextbd)), dbesc('birthday'));
intval($rr['uid']), intval($rr['id']), dbesc(DateTimeFormat::utc($nextbd)), dbesc('birthday'));
if (DBM::is_result($s)) {
continue;
@ -1508,8 +1508,8 @@ class Contact extends BaseObject
q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`)
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']),
dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::utc($nextbd)),
dbesc(Temporal::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
dbesc(DateTimeFormat::utcNow()), dbesc(DateTimeFormat::utcNow()), dbesc(DateTimeFormat::utc($nextbd)),
dbesc(DateTimeFormat::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
intval(0)
);

View file

@ -14,8 +14,8 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
use Exception;
@ -120,12 +120,12 @@ class GContact
intval($uid),
intval($gcid),
intval($zcid),
dbesc(Temporal::utcNow())
dbesc(DateTimeFormat::utcNow())
);
} else {
q(
"UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d",
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
intval($cid),
intval($uid),
intval($gcid),
@ -717,8 +717,8 @@ class GContact
dbesc($contact["url"]),
dbesc(normalise_link($contact["url"])),
dbesc($contact["photo"]),
dbesc(Temporal::utcNow()),
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
dbesc(DateTimeFormat::utcNow()),
dbesc($contact["location"]),
dbesc($contact["about"]),
intval($contact["hide"]),
@ -1050,7 +1050,7 @@ class GContact
foreach ($r as $server) {
self::fetchGsUsers($server["url"]);
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::utcNow()), dbesc($server["nurl"]));
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(DateTimeFormat::utcNow()), dbesc($server["nurl"]));
}
}

View file

@ -22,6 +22,7 @@ use Friendica\Model\Term;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use dba;
use Text_LanguageDetect;
@ -149,7 +150,7 @@ class Item extends BaseObject
// Set the item to "deleted"
dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
['id' => $item['id']]);
create_tags_from_item($item['id']);

View file

@ -10,7 +10,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use dba;
require_once 'include/dba.php';
@ -82,7 +82,7 @@ class Mail
$handles = $recip_handle . ';' . $sender_handle;
$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
if (dba::insert('conv', $fields)) {
$convid = dba::lastInsertId();
@ -116,7 +116,7 @@ class Mail
'replied' => 0,
'uri' => $uri,
'parent-uri' => $replyto,
'created' => Temporal::utcNow()
'created' => DateTimeFormat::utcNow()
]
);
@ -196,7 +196,7 @@ class Mail
$convid = null;
$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
if (dba::insert('conv', $fields)) {
$convid = dba::lastInsertId();
@ -224,7 +224,7 @@ class Mail
'replied' => 0,
'uri' => $uri,
'parent-uri' => $replyto,
'created' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(),
'unknown' => 1
]
);

View file

@ -12,8 +12,8 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
require_once 'include/dba.php';
@ -55,8 +55,8 @@ class Photo
'contact-id' => $cid,
'guid' => $guid,
'resource-id' => $rid,
'created' => Temporal::utcNow(),
'edited' => Temporal::utcNow(),
'created' => DateTimeFormat::utcNow(),
'edited' => DateTimeFormat::utcNow(),
'filename' => basename($filename),
'type' => $Image->getType(),
'album' => $album,

View file

@ -5,7 +5,7 @@
namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use dba;
require_once 'include/dba.php';
@ -34,7 +34,7 @@ class Process extends BaseObject
dba::transaction();
if (!dba::exists('process', ['pid' => $pid])) {
$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::utcNow()]);
$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
}
dba::commit();

View file

@ -17,8 +17,8 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
require_once 'include/dba.php';
@ -556,8 +556,8 @@ class Profile
WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
ORDER BY `start` ASC ",
local_user(),
Temporal::utc('now + 6 days'),
Temporal::utcNow()
DateTimeFormat::utc('now + 6 days'),
DateTimeFormat::utcNow()
);
if (DBM::is_result($s)) {
$r = dba::inArray($s);
@ -600,7 +600,7 @@ class Profile
$rr['link'] = $url;
$rr['title'] = $rr['name'];
$rr['date'] = day_translate(Temporal::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
$rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
$rr['startime'] = null;
$rr['today'] = $today;
}
@ -644,8 +644,8 @@ class Profile
WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
ORDER BY `start` ASC ",
local_user(),
Temporal::utc('now + 7 days'),
Temporal::utc('now - 1 days')
DateTimeFormat::utc('now + 7 days'),
DateTimeFormat::utc('now - 1 days')
);
$r = [];
@ -658,8 +658,8 @@ class Profile
$total ++;
}
$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
if ($strt === Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
$strt = DateTimeFormat::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
if ($strt === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
$istoday = true;
}
@ -674,17 +674,17 @@ class Profile
$description = L10n::t('[No description]');
}
$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
$strt = DateTimeFormat::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
if (substr($strt, 0, 10) < Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
continue;
}
$today = ((substr($strt, 0, 10) === Temporal::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
$today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
$rr['title'] = $title;
$rr['description'] = $description;
$rr['date'] = day_translate(Temporal::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
$rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
$rr['startime'] = $strt;
$rr['today'] = $today;
@ -731,8 +731,8 @@ class Profile
$val = day_translate(
intval($a->profile['dob']) ?
Temporal::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
: Temporal::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
: DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
);
$profile['birthday'] = [L10n::t('Birthday:'), $val];

View file

@ -6,7 +6,7 @@ namespace Friendica\Model;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use dba;
require_once 'include/dba.php';
@ -20,7 +20,7 @@ class Queue
public static function updateTime($id)
{
logger('queue: requeue item ' . $id);
dba::update('queue', ['last' => Temporal::utcNow()], ['id' => $id]);
dba::update('queue', ['last' => DateTimeFormat::utcNow()], ['id' => $id]);
}
/**
@ -95,6 +95,13 @@ class Queue
}
}
dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::utcNow(), 'last' => Temporal::utcNow(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
dba::insert('queue', [
'cid' => $cid,
'network' => $network,
'created' => DateTimeFormat::utcNow(),
'last' => DateTimeFormat::utcNow(),
'content' => $msg,
'batch' =>($batch) ? 1 : 0
]);
}
}

View file

@ -17,8 +17,8 @@ use Friendica\Model\Group;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba;
use Exception;
use LightOpenID;
@ -396,7 +396,7 @@ class User
'verified' => $verified,
'blocked' => $blocked,
'timezone' => 'UTC',
'register_date' => Temporal::utcNow(),
'register_date' => DateTimeFormat::utcNow(),
'default-location' => ''
]);
@ -613,7 +613,7 @@ class User
dba::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::utcNow()], ['uid' => $uid]);
dba::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory