function api_date($str)
{
// Wed May 23 06:01:13 +0000 2007
- return Temporal::convert($str, 'UTC', 'UTC', "D M d H:i:s +0000 Y");
+ return Temporal::utc($str, "D M d H:i:s +0000 Y");
}
/**
'@attributes' => ["type" => "integer"],
'hourly-limit' => '150',
'@attributes2' => ["type" => "integer"],
- 'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM),
+ 'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM),
'@attributes3' => ["type" => "datetime"],
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'@attributes4' => ["type" => "integer"],
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'remaining_hits' => '150',
'hourly_limit' => '150',
- 'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM)),
+ 'reset_time' => api_date(Temporal::utc('now + 1 hour', Temporal::ATOM)),
];
}
// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
$o .= L10n::t('Starts:') . ' ' . '['
- . (($ev['adjust']) ? day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
- : day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
+ . (($ev['adjust']) ? day_translate(Temporal::utc($ev['start'], $bd_format))
+ : day_translate(Temporal::convert($ev['start'], $bd_format))
)
- . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['start'])) . ")\n";
+ . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n";
if (! $ev['nofinish']) {
$o .= L10n::t('Finishes:') . ' ' . '['
- . (($ev['adjust']) ? day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
- : day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
+ . (($ev['adjust']) ? day_translate(Temporal::utc($ev['finish'], $bd_format))
+ : day_translate(Temporal::utc($ev['finish'], $bd_format))
)
- . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['finish'])) . ")\n";
+ . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n";
}
if (strlen($ev['location'])) {
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM.
- $event_start = (($ev['adjust']) ?
- day_translate(Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format))
- : day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format)));
+ $event_start = day_translate(
+ $ev['adjust'] ?
+ Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format)
+ : Temporal::utc($ev['start'], $bd_format)
+ );
- $event_end = (($ev['adjust']) ?
- day_translate(Temporal::convert($ev['finish'] , date_default_timezone_get(), 'UTC', $bd_format ))
- : day_translate(Temporal::convert($ev['finish'] , 'UTC', 'UTC', $bd_format )));
+ $event_end = day_translate(
+ $ev['adjust'] ?
+ Temporal::convert($ev['finish'], date_default_timezone_get(), 'UTC', $bd_format)
+ : Temporal::utc($ev['finish'], $bd_format)
+ );
if ($simple) {
$o = "<h3>" . bbcode($ev['summary']) . "</h3>";
$o .= '<div class="summary event-summary">' . bbcode($ev['summary']) . '</div>' . "\r\n";
$o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span> <span class="dtstart" title="'
- . Temporal::convert($ev['start'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
+ . Temporal::utc($ev['start'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
. '" >'.$event_start
. '</span></div>' . "\r\n";
if (! $ev['nofinish']) {
$o .= '<div class="event-end" ><span class="event-label">' . L10n::t('Finishes:') . '</span> <span class="dtend" title="'
- . Temporal::convert($ev['finish'], 'UTC', 'UTC', (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
+ . Temporal::utc($ev['finish'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' ))
. '" >'.$event_end
. '</span></div>' . "\r\n";
}
$fmt = L10n::t('l, F j');
if (count($arr)) {
foreach ($arr as $rr) {
- $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
- $d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::convert($rr['start'], 'UTC', 'UTC', $fmt));
+ $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'));
+ $d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::utc($rr['start'], $fmt));
$d = day_translate($d);
- $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'c'));
+ $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['start'], 'c'));
if ($rr['nofinish']) {
$end = null;
} else {
- $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['finish'], 'UTC', 'UTC', 'c'));
+ $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['finish'], 'c'));
}
$is_first = ($d !== $last_date);
$tformat = L10n::t('g:i A'); // 8:01 AM.
// Convert the time to different formats.
- $dtstart_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat)));
- $dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
+ $dtstart_dt = day_translate(
+ $item['event-adjust'] ?
+ Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)
+ : Temporal::utc($item['event-start'], $dformat)
+ );
+ $dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s');
// Format: Jan till Dec.
- $month_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', 'M')));
+ $month_short = day_short_translate(
+ $item['event-adjust'] ?
+ Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')
+ : Temporal::utc($item['event-start'], 'M')
+ );
// Format: 1 till 31.
- $date_short = (($item['event-adjust']) ? Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($item['event-start'], 'UTC', 'UTC', 'j'));
- $start_time = (($item['event-adjust']) ? Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-start'], 'UTC', 'UTC', $tformat));
- $start_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat_short)));
+ $date_short = $item['event-adjust'] ?
+ Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j')
+ : Temporal::utc($item['event-start'], 'j');
+ $start_time = $item['event-adjust'] ?
+ Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat)
+ : Temporal::utc($item['event-start'], $tformat);
+ $start_short = day_short_translate(
+ $item['event-adjust'] ?
+ Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short)
+ : Temporal::utc($item['event-start'], $dformat_short)
+ );
// If the option 'nofinisch' isn't set, we need to format the finish date/time.
if (!$item['event-nofinish']) {
$finish = true;
- $dtend_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat)));
- $dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s'));
- $end_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat_short)));
- $end_time = (($item['event-adjust']) ? Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-finish'], 'UTC', 'UTC', $tformat));
+ $dtend_dt = day_translate(
+ $item['event-adjust'] ?
+ Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)
+ : Temporal::utc($item['event-finish'], $dformat)
+ );
+ $dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s');
+ $end_short = day_short_translate(
+ $item['event-adjust'] ?
+ Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)
+ : Temporal::utc($item['event-finish'], $dformat_short)
+ );
+ $end_time = $item['event-adjust'] ?
+ Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat)
+ : Temporal::utc($item['event-finish'], $tformat);
// Check if start and finish time is at the same day.
if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) {
$same_date = true;
$dyear = intval(substr($dnow, 0, 4));
$dstart = substr($dnow, 0, 8) . '01';
$dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5)));
- $start_month = Temporal::convert($dstart, 'UTC', 'UTC', 'Y-m-d');
- $end_month = Temporal::convert($dend, 'UTC', 'UTC', 'Y-m-d');
- $str = day_translate(Temporal::convert($dnow, 'UTC', 'UTC', 'F'));
+ $start_month = Temporal::utc($dstart, 'Y-m-d');
+ $end_month = Temporal::utc($dend, 'Y-m-d');
+ $str = day_translate(Temporal::utc($dnow, 'F'));
if (!$ret[$dyear]) {
$ret[$dyear] = [];
}
$ret[$dyear][] = [$str, $end_month, $start_month];
- $dnow = Temporal::convert($dnow . ' -1 month', 'UTC', 'UTC', 'Y-m-d');
+ $dnow = Temporal::utc($dnow . ' -1 month', 'Y-m-d');
}
return $ret;
}
}
}
- $start = Temporal::convert($start);
- $finish = Temporal::convert($finish);
+ $start = Temporal::utc($start);
+ $finish = Temporal::utc($finish);
$adjust_start = Temporal::convert($start, date_default_timezone_get());
$adjust_finish = Temporal::convert($finish, date_default_timezone_get());
if (DBM::is_result($r)) {
$r = sort_by_date($r);
foreach ($r as $rr) {
- $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
+ $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j');
if (!x($links, $j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
// Block friend request spam
if ($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
- dbesc(Temporal::convert('now - 24 hours')),
+ dbesc(Temporal::utc('now - 24 hours')),
intval($uid)
);
if (DBM::is_result($r) && count($r) > $maxreq) {
$finish = Temporal::convert($finish, 'UTC', date_default_timezone_get());
}
} else {
- $start = Temporal::convert($start);
+ $start = Temporal::utc($start);
if (! $nofinish) {
- $finish = Temporal::convert($finish);
+ $finish = Temporal::utc($finish);
}
}
}
}
- $start = Temporal::convert($start);
- $finish = Temporal::convert($finish);
+ $start = Temporal::utc($start);
+ $finish = Temporal::utc($finish);
$adjust_start = Temporal::convert($start, date_default_timezone_get());
$adjust_finish = Temporal::convert($finish, date_default_timezone_get());
if (DBM::is_result($r)) {
$r = sort_by_date($r);
foreach ($r as $rr) {
- $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
+ $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j');
if (! x($links,$j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
}
// Password reset requests expire in 60 minutes
- if ($user['pwdreset_time'] < Temporal::convert('now - 1 hour')) {
+ if ($user['pwdreset_time'] < Temporal::utc('now - 1 hour')) {
$fields = [
'pwdreset' => null,
'pwdreset_time' => null
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
ORDER BY `start` ASC ",
intval(local_user()),
- dbesc(Temporal::convert('now + 7 days')),
+ dbesc(Temporal::utc('now + 7 days')),
dbesc(Temporal::utcNow())
);
if (DBM::is_result($ev)) {
$ignore_year = true;
$dob = substr($dob, 5);
}
- $dob = Temporal::convert((($ignore_year) ? '1900-' . $dob : $dob), 'UTC', 'UTC', (($ignore_year) ? 'm-d' : 'Y-m-d'));
if ($ignore_year) {
- $dob = '0000-' . $dob;
+ $dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d');
+ } else {
+ $dob = Temporal::utc($dob, 'Y-m-d');
}
}
if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
if ($max_level == CACHE_MONTH) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 30 days"),
+ Temporal::utc("now - 30 days"),
CACHE_MONTH];
dba::delete('cache', $condition);
}
if ($max_level <= CACHE_WEEK) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 7 days"),
+ Temporal::utc("now - 7 days"),
CACHE_WEEK];
dba::delete('cache', $condition);
}
if ($max_level <= CACHE_DAY) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 1 days"),
+ Temporal::utc("now - 1 days"),
CACHE_DAY];
dba::delete('cache', $condition);
}
if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 1 hours"),
+ Temporal::utc("now - 1 hours"),
CACHE_HOUR];
dba::delete('cache', $condition);
if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 30 minutes"),
+ Temporal::utc("now - 30 minutes"),
CACHE_HALF_HOUR];
dba::delete('cache', $condition);
if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 15 minutes"),
+ Temporal::utc("now - 15 minutes"),
CACHE_QUARTER_HOUR];
dba::delete('cache', $condition);
if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 5 minutes"),
+ Temporal::utc("now - 5 minutes"),
CACHE_FIVE_MINUTES];
dba::delete('cache', $condition);
if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
$condition = ["`updated` < ? AND `expire_mode` = ?",
- Temporal::convert("now - 1 minutes"),
+ Temporal::utc("now - 1 minutes"),
CACHE_MINUTE];
dba::delete('cache', $condition);
/// @todo We should clean up the corresponding workerqueue entries as well
$condition = ["`created` < ? AND `command` = 'worker.php'",
- Temporal::convert("now - ".$timeout." minutes")];
+ Temporal::utc("now - ".$timeout." minutes")];
dba::delete('process', $condition);
}
/// @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.
$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')) {
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
// 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;
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)
);
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)) {
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 = [];
$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];
}
if (!x($_SESSION['last_login_date'])) {
$_SESSION['last_login_date'] = Temporal::utcNow();
}
- if (strcmp(Temporal::convert('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
+ if (strcmp(Temporal::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
$_SESSION['last_login_date'] = Temporal::utcNow();
$login_refresh = true;
}
$comment = $this->getCommentBox($indent);
- if (strcmp(Temporal::convert($item['created']), Temporal::convert('now - 12 hours')) > 0) {
+ if (strcmp(Temporal::utc($item['created']), Temporal::utc('now - 12 hours')) > 0) {
$shiny = 'shiny';
}
}
}
- $check_date = Temporal::convert($last_update);
+ $check_date = Temporal::utc($last_update);
$r = q(
"SELECT `item`.*, `item`.`id` AS `item_id`,
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', Temporal::ATOM));
+ XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::utc($item['created'] . '+00:00', Temporal::ATOM));
XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
- XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM));
+ XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
$author = self::addAuthor($doc, $owner, $authorelement, $public);
$root->appendChild($author);
$author = $doc->createElement($authorelement);
- $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
- $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
- $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM);
+ $namdate = Temporal::utc($owner['name-date'].'+00:00', Temporal::ATOM);
+ $uridate = Temporal::utc($owner['uri-date'].'+00:00', Temporal::ATOM);
+ $picdate = Temporal::utc($owner['avatar-date'].'+00:00', Temporal::ATOM);
$attributes = [];
}
if ($item['deleted']) {
- $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)];
+ $attributes = ["ref" => $item['uri'], "when" => Temporal::utc($item['edited'] . '+00:00', Temporal::ATOM)];
return XML::createElement($doc, "at:deleted-entry", "", $attributes);
}
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", Temporal::ATOM));
- XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", Temporal::ATOM));
+ XML::addElement($doc, $entry, "published", Temporal::utc($item["created"] . "+00:00", Temporal::ATOM));
+ XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"] . "+00:00", Temporal::ATOM));
// "dfrn:env" is used to read the content
XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
"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(Temporal::utc($birthday)),
dbesc("birthday")
);
intval($contact["id"]),
dbesc(Temporal::utcNow()),
dbesc(Temporal::utcNow()),
- dbesc(Temporal::convert($birthday)),
- dbesc(Temporal::convert($birthday . " + 1 day ")),
+ dbesc(Temporal::utc($birthday)),
+ dbesc(Temporal::utc($birthday . " + 1 day ")),
dbesc($bdtext),
dbesc($bdtext2),
dbesc("birthday")
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 (Temporal::utc($item["edited"]) < $current["edited"]) {
return false;
}
$fields = ['title' => $item["title"], 'body' => $item["body"],
'tag' => $item["tag"], 'changed' => Temporal::utcNow(),
- 'edited' => Temporal::convert($item["edited"])];
+ 'edited' => Temporal::utc($item["edited"])];
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
dba::update('item', $fields, $condition);
// Is there an existing item?
if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
- && (Temporal::convert($item["edited"]) < $current[0]["edited"])
+ && (Temporal::utc($item["edited"]) < $current[0]["edited"])
) {
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
return;
}
}
if ($when) {
- $when = Temporal::convert($when);
+ $when = Temporal::utc($when);
} else {
- $when = Temporal::convert("now");
+ $when = Temporal::utcNow();
}
if (!$uri || !$importer["id"]) {
return false;
}
- $existing_edited = Temporal::convert($existing['edited']);
- $update_edited = Temporal::convert($update['edited']);
+ $existing_edited = Temporal::utc($existing['edited']);
+ $update_edited = Temporal::utc($update['edited']);
return (strcmp($existing_edited, $update_edited) < 0);
}
$text = unxmlify($data->text);
if (isset($data->created_at)) {
- $created_at = Temporal::convert(notags(unxmlify($data->created_at)));
+ $created_at = Temporal::utc(notags(unxmlify($data->created_at)));
} else {
$created_at = Temporal::utcNow();
}
$msg_guid = notags(unxmlify($mesg->guid));
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
$msg_text = unxmlify($mesg->text);
- $msg_created_at = Temporal::convert(notags(unxmlify($mesg->created_at)));
+ $msg_created_at = Temporal::utc(notags(unxmlify($mesg->created_at)));
if ($msg_conversation_guid != $guid) {
logger("message conversation guid does not belong to the current conversation.");
$author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid));
$subject = notags(unxmlify($data->subject));
- $created_at = Temporal::convert(notags(unxmlify($data->created_at)));
+ $created_at = Temporal::utc(notags(unxmlify($data->created_at)));
$participants = notags(unxmlify($data->participants));
$messages = $data->message;
$guid = notags(unxmlify($data->guid));
$conversation_guid = notags(unxmlify($data->conversation_guid));
$text = unxmlify($data->text);
- $created_at = Temporal::convert(notags(unxmlify($data->created_at)));
+ $created_at = Temporal::utc(notags(unxmlify($data->created_at)));
$contact = self::allowedContactByHandle($importer, $author, true);
if (!$contact) {
$birthday = str_replace("1000", "1901", $birthday);
if ($birthday != "") {
- $birthday = Temporal::convert($birthday, "UTC", "UTC", "Y-m-d");
+ $birthday = Temporal::utc($birthday, "Y-m-d");
}
// this is to prevent multiple birthday notifications in a single year
{
$author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid));
- $created_at = Temporal::convert(notags(unxmlify($data->created_at)));
+ $created_at = Temporal::utc(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"
{
$author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid));
- $created_at = Temporal::convert(notags(unxmlify($data->created_at)));
+ $created_at = Temporal::utc(notags(unxmlify($data->created_at)));
$public = notags(unxmlify($data->public));
$text = unxmlify($data->text);
$provider_display_name = notags(unxmlify($data->provider_display_name));
$public = (($item["private"]) ? "false" : "true");
- $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
+ $created = Temporal::utc($item["created"], Temporal::ATOM);
// Detect a share element and do a reshare
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
$parent = $p[0];
$text = html_entity_decode(bb2diaspora($item["body"]));
- $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
+ $created = Temporal::utc($item["created"], Temporal::ATOM);
$comment = ["author" => self::myHandle($owner),
"guid" => $item["guid"],
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
- "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM),
+ "created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
"participants" => $cnv["recips"]
];
$body = bb2diaspora($item["body"]);
- $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM);
+ $created = Temporal::utc($item["created"], Temporal::ATOM);
$msg = [
"author" => $myaddr,
"author" => $cnv["creator"],
"guid" => $cnv["guid"],
"subject" => $cnv["subject"],
- "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM),
+ "created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
"participants" => $cnv["recips"],
"message" => $msg];
if ($year < 1004) {
$year = 1004;
}
- $dob = Temporal::convert($year . '-' . $month . '-'. $day, 'UTC', 'UTC', 'Y-m-d');
+ $dob = Temporal::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
}
$about = $profile['about'];
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", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM));
+ XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
$author = self::addAuthor($doc, $owner);
$root->appendChild($author);
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", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", Temporal::ATOM));
+ XML::addElement($doc, $source, "updated", Temporal::utc($contact["success_update"]."+00:00", Temporal::ATOM));
return $source;
}
XML::addElement($doc, $entry, "activity:verb", $verb);
- XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", Temporal::ATOM));
- XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", Temporal::ATOM));
+ XML::addElement($doc, $entry, "published", Temporal::utc($item["created"]."+00:00", Temporal::ATOM));
+ XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"]."+00:00", Temporal::ATOM));
}
/**
$last_update = 'now -30 days';
}
- $check_date = Temporal::convert($last_update);
+ $check_date = Temporal::utc($last_update);
$authorid = Contact::getIdForURL($owner["url"], 0);
$sql_extra = '';
*/
public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '')
{
- $options = Temporal::getTimezoneSelect($current);
+ $options = self::getTimezoneSelect($current);
$options = str_replace('<select id="timezone_select" name="timezone">', '', $options);
$options = str_replace('</select>', '', $options);
]);
}
+ /**
+ * convert() shorthand for UTC.
+ *
+ * @param string $time A date/time string
+ * @param string $format DateTime format string or Temporal constant
+ * @return string
+ */
+ public static function utc($time, $format = self::MYSQL)
+ {
+ return self::convert($time, 'UTC', 'UTC', $format);
+ }
+
/**
* convert() shorthand for UTC now.
*
if ($dob < '0000-01-01') {
$value = '';
} else {
- $value = Temporal::convert(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'UTC', 'UTC', 'Y-m-d');
+ $value = self::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d');
}
$age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
$viewer_tz = date_default_timezone_get();
}
- $birthdate = Temporal::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d');
+ $birthdate = self::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d');
list($year, $month, $day) = explode("-", $birthdate);
- $year_diff = Temporal::convert('now', $viewer_tz, 'UTC', 'Y') - $year;
- $curr_month = Temporal::convert('now', $viewer_tz, 'UTC', 'm');
- $curr_day = Temporal::convert('now', $viewer_tz, 'UTC', 'd');
+ $year_diff = self::convert('now', $viewer_tz, 'UTC', 'Y') - $year;
+ $curr_month = self::convert('now', $viewer_tz, 'UTC', 'm');
+ $curr_day = self::convert('now', $viewer_tz, 'UTC', 'd');
if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) {
$year_diff--;
{
$d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m));
- return Temporal::convert($d, 'UTC', 'UTC', 'w');
+ return self::utc($d, 'w');
}
/**
'October', 'November', 'December'
];
- $thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
- $thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm');
+ $thisyear = self::convert('now', date_default_timezone_get(), 'UTC', 'Y');
+ $thismonth = self::convert('now', date_default_timezone_get(), 'UTC', 'm');
if (!$y) {
$y = $thisyear;
}
$started = false;
if (($y == $thisyear) && ($m == $thismonth)) {
- $tddate = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'j'));
+ $tddate = intval(self::convert('now', date_default_timezone_get(), 'UTC', 'j'));
}
$str_month = day_translate($mtab[$m]);
*/
switch ($contact['priority']) {
case 5:
- if (Temporal::utcNow() > Temporal::convert($t . " + 1 month")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 1 month")) {
$update = true;
}
break;
case 4:
- if (Temporal::utcNow() > Temporal::convert($t . " + 1 week")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 1 week")) {
$update = true;
}
break;
case 3:
- if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) {
$update = true;
}
break;
case 2:
- if (Temporal::utcNow() > Temporal::convert($t . " + 12 hour")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 12 hour")) {
$update = true;
}
break;
case 1:
- if (Temporal::utcNow() > Temporal::convert($t . " + 1 hour")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 1 hour")) {
$update = true;
}
break;
case 0:
default:
- if (Temporal::utcNow() > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + ".$min_poll_interval." minute")) {
$update = true;
}
break;
$contact['priority'] = intval($poll_interval);
$hub_update = false;
- if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
+ if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) {
$hub_update = true;
}
} else {
}
$last_update = (($contact['last-update'] <= NULL_DATE)
- ? Temporal::convert('now - 7 days', 'UTC', 'UTC', Temporal::ATOM)
- : Temporal::convert($contact['last-update'], 'UTC', 'UTC', Temporal::ATOM)
+ ? Temporal::utc('now - 7 days', Temporal::ATOM)
+ : Temporal::utc($contact['last-update'], Temporal::ATOM)
);
// Update the contact entry
$datarray['title'] = notags(trim($datarray['title']));
//$datarray['title'] = notags(trim($meta->subject));
- $datarray['created'] = Temporal::convert($meta->date);
+ $datarray['created'] = Temporal::utc($meta->date);
// Is it a reply?
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||