Add Temporal::utc() shorthand to Temporal::convert()

This commit is contained in:
Hypolite Petovan 2018-01-26 07:29:32 -05:00
parent ca8209a2ce
commit 35d06bd9eb
22 changed files with 173 additions and 128 deletions

View file

@ -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::convert($expiry)) {
if (Temporal::utcNow() > Temporal::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::convert('now -7 days'));
$update_contact = ($contact['avatar-date'] < Temporal::utc('now -7 days'));
// We force the update if the avatar is empty
if (!x($contact, 'avatar')) {
@ -1485,7 +1485,7 @@ class Contact extends BaseObject
foreach ($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);
$nextbd = Temporal::convert('Y') . substr($rr['bd'], 4);
$nextbd = Temporal::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::convert($nextbd)), dbesc('birthday'));
intval($rr['uid']), intval($rr['id']), dbesc(Temporal::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::convert($nextbd)),
dbesc(Temporal::convert($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::utc($nextbd)),
dbesc(Temporal::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
intval(0)
);

View file

@ -556,7 +556,7 @@ class Profile
WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
ORDER BY `start` ASC ",
local_user(),
Temporal::convert('now + 6 days'),
Temporal::utc('now + 6 days'),
Temporal::utcNow()
);
if (DBM::is_result($s)) {
@ -644,8 +644,8 @@ class Profile
WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
ORDER BY `start` ASC ",
local_user(),
Temporal::convert('now + 7 days'),
Temporal::convert('now - 1 days')
Temporal::utc('now + 7 days'),
Temporal::utc('now - 1 days')
);
$r = [];
@ -729,9 +729,11 @@ class Profile
$year_bd_format = L10n::t('j F, Y');
$short_bd_format = L10n::t('j F');
$val = intval($a->profile['dob']) ?
day_translate(Temporal::convert($a->profile['dob'] . ' 00:00 +00:00', 'UTC', 'UTC', $year_bd_format))
: day_translate(Temporal::convert('2001-' . substr($a->profile['dob'], 'UTC', 'UTC', 5) . ' 00:00 +00:00', $short_bd_format));
$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)
);
$profile['birthday'] = [L10n::t('Birthday:'), $val];
}