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

@ -28,7 +28,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use Friendida\Core\L10n; use Friendida\Core\L10n;
require_once 'include/text.php'; require_once 'include/text.php';
@ -1142,14 +1142,14 @@ function feed_birthday($uid, $tz)
if (DBM::is_result($p)) { if (DBM::is_result($p)) {
$tmp_dob = substr($p[0]['dob'], 5); $tmp_dob = substr($p[0]['dob'], 5);
if (intval($tmp_dob)) { if (intval($tmp_dob)) {
$y = Temporal::timezoneNow($tz, 'Y'); $y = DateTimeFormat::timezoneNow($tz, 'Y');
$bd = $y . '-' . $tmp_dob . ' 00:00'; $bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd); $t_dob = strtotime($bd);
$now = strtotime(Temporal::timezoneNow($tz)); $now = strtotime(DateTimeFormat::timezoneNow($tz));
if ($t_dob < $now) { if ($t_dob < $now) {
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
} }
$birthday = Temporal::convert($bd, 'UTC', $tz, Temporal::ATOM); $birthday = DateTimeFormat::convert($bd, 'UTC', $tz, DateTimeFormat::ATOM);
} }
} }

View file

@ -36,8 +36,8 @@ use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Network\HTTPException\UnauthorizedException; use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
@ -111,7 +111,7 @@ function api_source()
function api_date($str) function api_date($str)
{ {
// Wed May 23 06:01:13 +0000 2007 // Wed May 23 06:01:13 +0000 2007
return Temporal::utc($str, "D M d H:i:s +0000 Y"); return DateTimeFormat::utc($str, "D M d H:i:s +0000 Y");
} }
/** /**
@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info)
'self' => System::baseUrl() . "/" . $a->query_string, 'self' => System::baseUrl() . "/" . $a->query_string,
'base' => System::baseUrl(), 'base' => System::baseUrl(),
'updated' => api_date(null), 'updated' => api_date(null),
'atom_updated' => Temporal::utcNow(Temporal::ATOM), 'atom_updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'language' => $user_info['language'], 'language' => $user_info['language'],
'logo' => System::baseUrl() . "/images/friendica-32.png", 'logo' => System::baseUrl() . "/images/friendica-32.png",
]; ];
@ -1162,7 +1162,7 @@ function api_statuses_update($type)
// Check for throttling (maximum posts per day, week and month) // Check for throttling (maximum posts per day, week and month)
$throttle_day = Config::get('system', 'throttle_limit_day'); $throttle_day = Config::get('system', 'throttle_limit_day');
if ($throttle_day > 0) { if ($throttle_day > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$r = q( $r = q(
"SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall` "SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall`
@ -1186,7 +1186,7 @@ function api_statuses_update($type)
$throttle_week = Config::get('system', 'throttle_limit_week'); $throttle_week = Config::get('system', 'throttle_limit_week');
if ($throttle_week > 0) { if ($throttle_week > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60*7); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$r = q( $r = q(
"SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall` "SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall`
@ -1210,7 +1210,7 @@ function api_statuses_update($type)
$throttle_month = Config::get('system', 'throttle_limit_month'); $throttle_month = Config::get('system', 'throttle_limit_month');
if ($throttle_month > 0) { if ($throttle_month > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60*30); $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$r = q( $r = q(
"SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall` "SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall`
@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type)
'@attributes' => ["type" => "integer"], '@attributes' => ["type" => "integer"],
'hourly-limit' => '150', 'hourly-limit' => '150',
'@attributes2' => ["type" => "integer"], '@attributes2' => ["type" => "integer"],
'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM), 'reset-time' => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM),
'@attributes3' => ["type" => "datetime"], '@attributes3' => ["type" => "datetime"],
'reset_time_in_seconds' => strtotime('now + 1 hour'), 'reset_time_in_seconds' => strtotime('now + 1 hour'),
'@attributes4' => ["type" => "integer"], '@attributes4' => ["type" => "integer"],
@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type)
'reset_time_in_seconds' => strtotime('now + 1 hour'), 'reset_time_in_seconds' => strtotime('now + 1 hour'),
'remaining_hits' => '150', 'remaining_hits' => '150',
'hourly_limit' => '150', 'hourly_limit' => '150',
'reset_time' => api_date(Temporal::utc('now + 1 hour', Temporal::ATOM)), 'reset_time' => api_date(DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM)),
]; ];
} }
@ -4216,7 +4216,7 @@ function api_fr_photo_create_update($type)
$result = q( $result = q(
"UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'", "UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'",
$sql_extra, $sql_extra,
Temporal::utcNow(), // update edited timestamp DateTimeFormat::utcNow(), // update edited timestamp
intval(api_user()), intval(api_user()),
dbesc($photo_id), dbesc($photo_id),
dbesc($album) dbesc($album)
@ -4420,7 +4420,7 @@ function api_account_update_profile_image($type)
q( q(
"UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", "UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval(local_user()) intval(local_user())
); );

View file

@ -7,7 +7,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use League\HTMLToMarkdown\HtmlConverter; use League\HTMLToMarkdown\HtmlConverter;
require_once 'include/event.php'; require_once 'include/event.php';
@ -245,15 +245,15 @@ function format_event_diaspora($ev) {
// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan // @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
$o .= L10n::t('Starts:') . ' ' . '[' . day_translate( $o .= L10n::t('Starts:') . ' ' . '[' . day_translate(
$ev['adjust'] ? Temporal::utc($ev['start'], $bd_format) : Temporal::utc($ev['start'], $bd_format) $ev['adjust'] ? DateTimeFormat::utc($ev['start'], $bd_format) : DateTimeFormat::utc($ev['start'], $bd_format)
) )
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n"; . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['start'])) . ")\n";
if (! $ev['nofinish']) { if (! $ev['nofinish']) {
$o .= L10n::t('Finishes:') . ' ' . '[' . day_translate( $o .= L10n::t('Finishes:') . ' ' . '[' . day_translate(
$ev['adjust'] ? Temporal::utc($ev['finish'], $bd_format) : Temporal::utc($ev['finish'], $bd_format) $ev['adjust'] ? DateTimeFormat::utc($ev['finish'], $bd_format) : DateTimeFormat::utc($ev['finish'], $bd_format)
) )
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n"; . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['finish'])) . ")\n";
} }
if (strlen($ev['location'])) { if (strlen($ev['location'])) {

View file

@ -17,7 +17,7 @@ use Friendica\Model\Profile;
use Friendica\Object\Post; use Friendica\Object\Post;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Object\Thread; use Friendica\Object\Thread;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once "include/bbcode.php"; require_once "include/bbcode.php";
require_once "include/acl_selectors.php"; require_once "include/acl_selectors.php";
@ -790,7 +790,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'categories' => $categories, 'categories' => $categories,
'folders' => $folders, 'folders' => $folders,
'text' => strip_tags($body_e), 'text' => strip_tags($body_e),
'localtime' => Temporal::local($item['created'], 'r'), 'localtime' => DateTimeFormat::local($item['created'], 'r'),
'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])), 'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'location' => $location_e, 'location' => $location_e,
'indent' => '', 'indent' => '',

View file

@ -4,7 +4,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once('include/datetime.php'); require_once('include/datetime.php');
@ -190,7 +190,7 @@ class dba {
if ($log) { if ($log) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log_index"], Temporal::utcNow()."\t". @file_put_contents($a->config["system"]["db_log_index"], DateTimeFormat::utcNow()."\t".
$row['key']."\t".$row['rows']."\t".$row['Extra']."\t". $row['key']."\t".$row['rows']."\t".$row['Extra']."\t".
basename($backtrace[1]["file"])."\t". basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
@ -495,7 +495,7 @@ class dba {
$duration = round($duration, 3); $duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log"], Temporal::utcNow()."\t".$duration."\t". @file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t".
basename($backtrace[1]["file"])."\t". basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND); substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND);

View file

@ -8,8 +8,8 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer; use Friendica\Util\Emailer;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/html2bbcode.php'; require_once 'include/html2bbcode.php';
@ -451,7 +451,7 @@ function notification($params)
$datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['name_cache'] = strip_tags(bbcode($params['source_name']));
$datarray['url'] = $params['source_link']; $datarray['url'] = $params['source_link'];
$datarray['photo'] = $params['source_photo']; $datarray['photo'] = $params['source_photo'];
$datarray['date'] = Temporal::utcNow(); $datarray['date'] = DateTimeFormat::utcNow();
$datarray['uid'] = $params['uid']; $datarray['uid'] = $params['uid'];
$datarray['link'] = $itemlink; $datarray['link'] = $itemlink;
$datarray['iid'] = $item_id; $datarray['iid'] = $item_id;

View file

@ -12,8 +12,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -28,14 +28,14 @@ function format_event_html($ev, $simple = false) {
$event_start = day_translate( $event_start = day_translate(
$ev['adjust'] ? $ev['adjust'] ?
Temporal::local($ev['start'], $bd_format) DateTimeFormat::local($ev['start'], $bd_format)
: Temporal::utc($ev['start'], $bd_format) : DateTimeFormat::utc($ev['start'], $bd_format)
); );
$event_end = day_translate( $event_end = day_translate(
$ev['adjust'] ? $ev['adjust'] ?
Temporal::local($ev['finish'], $bd_format) DateTimeFormat::local($ev['finish'], $bd_format)
: Temporal::utc($ev['finish'], $bd_format) : DateTimeFormat::utc($ev['finish'], $bd_format)
); );
if ($simple) { if ($simple) {
@ -61,13 +61,13 @@ function format_event_html($ev, $simple = false) {
$o .= '<div class="summary event-summary">' . bbcode($ev['summary']) . '</div>' . "\r\n"; $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>&nbsp;<span class="dtstart" title="' $o .= '<div class="event-start"><span class="event-label">' . L10n::t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. Temporal::utc($ev['start'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' )) . DateTimeFormat::utc($ev['start'], (($ev['adjust']) ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s' ))
. '" >'.$event_start . '" >'.$event_start
. '</span></div>' . "\r\n"; . '</span></div>' . "\r\n";
if (! $ev['nofinish']) { if (! $ev['nofinish']) {
$o .= '<div class="event-end" ><span class="event-label">' . L10n::t('Finishes:') . '</span>&nbsp;<span class="dtend" title="' $o .= '<div class="event-end" ><span class="event-label">' . L10n::t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
. Temporal::utc($ev['finish'], (($ev['adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s' )) . DateTimeFormat::utc($ev['finish'], (($ev['adjust']) ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s' ))
. '" >'.$event_end . '" >'.$event_end
. '</span></div>' . "\r\n"; . '</span></div>' . "\r\n";
} }
@ -200,8 +200,8 @@ function sort_by_date($a) {
function ev_compare($a,$b) { function ev_compare($a,$b) {
$date_a = (($a['adjust']) ? Temporal::local($a['start']) : $a['start']); $date_a = (($a['adjust']) ? DateTimeFormat::local($a['start']) : $a['start']);
$date_b = (($b['adjust']) ? Temporal::local($b['start']) : $b['start']); $date_b = (($b['adjust']) ? DateTimeFormat::local($b['start']) : $b['start']);
if ($date_a === $date_b) { if ($date_a === $date_b) {
return strcasecmp($a['desc'], $b['desc']); return strcasecmp($a['desc'], $b['desc']);
@ -244,8 +244,8 @@ function event_store($arr) {
$a = get_app(); $a = get_app();
$arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::utcNow()); $arr['created'] = (($arr['created']) ? $arr['created'] : DateTimeFormat::utcNow());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::utcNow()); $arr['edited'] = (($arr['edited']) ? $arr['edited'] : DateTimeFormat::utcNow());
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
$arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid']));
@ -595,15 +595,15 @@ function process_events($arr) {
$fmt = L10n::t('l, F j'); $fmt = L10n::t('l, F j');
if (count($arr)) { if (count($arr)) {
foreach ($arr as $rr) { foreach ($arr as $rr) {
$j = (($rr['adjust']) ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j')); $j = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'));
$d = (($rr['adjust']) ? Temporal::local($rr['start'], $fmt) : Temporal::utc($rr['start'], $fmt)); $d = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], $fmt) : DateTimeFormat::utc($rr['start'], $fmt));
$d = day_translate($d); $d = day_translate($d);
$start = (($rr['adjust']) ? Temporal::local($rr['start'], 'c') : Temporal::utc($rr['start'], 'c')); $start = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], 'c') : DateTimeFormat::utc($rr['start'], 'c'));
if ($rr['nofinish']) { if ($rr['nofinish']) {
$end = null; $end = null;
} else { } else {
$end = (($rr['adjust']) ? Temporal::local($rr['finish'], 'c') : Temporal::utc($rr['finish'], 'c')); $end = (($rr['adjust']) ? DateTimeFormat::local($rr['finish'], 'c') : DateTimeFormat::utc($rr['finish'], 'c'));
} }
$is_first = ($d !== $last_date); $is_first = ($d !== $last_date);
@ -930,27 +930,27 @@ function format_event_item($item) {
// Convert the time to different formats. // Convert the time to different formats.
$dtstart_dt = day_translate( $dtstart_dt = day_translate(
$item['event-adjust'] ? $item['event-adjust'] ?
Temporal::local($item['event-start'], $dformat) DateTimeFormat::local($item['event-start'], $dformat)
: Temporal::utc($item['event-start'], $dformat) : DateTimeFormat::utc($item['event-start'], $dformat)
); );
$dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); $dtstart_title = DateTimeFormat::utc($item['event-start'], $item['event-adjust'] ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s');
// Format: Jan till Dec. // Format: Jan till Dec.
$month_short = day_short_translate( $month_short = day_short_translate(
$item['event-adjust'] ? $item['event-adjust'] ?
Temporal::local($item['event-start'], 'M') DateTimeFormat::local($item['event-start'], 'M')
: Temporal::utc($item['event-start'], 'M') : DateTimeFormat::utc($item['event-start'], 'M')
); );
// Format: 1 till 31. // Format: 1 till 31.
$date_short = $item['event-adjust'] ? $date_short = $item['event-adjust'] ?
Temporal::local($item['event-start'], 'j') DateTimeFormat::local($item['event-start'], 'j')
: Temporal::utc($item['event-start'], 'j'); : DateTimeFormat::utc($item['event-start'], 'j');
$start_time = $item['event-adjust'] ? $start_time = $item['event-adjust'] ?
Temporal::local($item['event-start'], $tformat) DateTimeFormat::local($item['event-start'], $tformat)
: Temporal::utc($item['event-start'], $tformat); : DateTimeFormat::utc($item['event-start'], $tformat);
$start_short = day_short_translate( $start_short = day_short_translate(
$item['event-adjust'] ? $item['event-adjust'] ?
Temporal::local($item['event-start'], $dformat_short) DateTimeFormat::local($item['event-start'], $dformat_short)
: Temporal::utc($item['event-start'], $dformat_short) : DateTimeFormat::utc($item['event-start'], $dformat_short)
); );
// If the option 'nofinisch' isn't set, we need to format the finish date/time. // If the option 'nofinisch' isn't set, we need to format the finish date/time.
@ -958,18 +958,18 @@ function format_event_item($item) {
$finish = true; $finish = true;
$dtend_dt = day_translate( $dtend_dt = day_translate(
$item['event-adjust'] ? $item['event-adjust'] ?
Temporal::local($item['event-finish'], $dformat) DateTimeFormat::local($item['event-finish'], $dformat)
: Temporal::utc($item['event-finish'], $dformat) : DateTimeFormat::utc($item['event-finish'], $dformat)
); );
$dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); $dtend_title = DateTimeFormat::utc($item['event-finish'], $item['event-adjust'] ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s');
$end_short = day_short_translate( $end_short = day_short_translate(
$item['event-adjust'] ? $item['event-adjust'] ?
Temporal::local($item['event-finish'], $dformat_short) DateTimeFormat::local($item['event-finish'], $dformat_short)
: Temporal::utc($item['event-finish'], $dformat_short) : DateTimeFormat::utc($item['event-finish'], $dformat_short)
); );
$end_time = $item['event-adjust'] ? $end_time = $item['event-adjust'] ?
Temporal::local($item['event-finish'], $tformat) DateTimeFormat::local($item['event-finish'], $tformat)
: Temporal::utc($item['event-finish'], $tformat); : DateTimeFormat::utc($item['event-finish'], $tformat);
// Check if start and finish time is at the same day. // Check if start and finish time is at the same day.
if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) { if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) {
$same_date = true; $same_date = true;

View file

@ -9,22 +9,14 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\Feed; use Friendica\Protocol\Feed;
use Friendica\Util\Network;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/tags.php'; require_once 'include/tags.php';
@ -416,7 +408,7 @@ function drop_item($id) {
/* arrange the list in years */ /* arrange the list in years */
function list_post_dates($uid, $wall) { function list_post_dates($uid, $wall) {
$dnow = Temporal::localNow('Y-m-d'); $dnow = DateTimeFormat::localNow('Y-m-d');
$dthen = Item::firstPostDate($uid, $wall); $dthen = Item::firstPostDate($uid, $wall);
if (!$dthen) { if (!$dthen) {
@ -437,14 +429,14 @@ function list_post_dates($uid, $wall) {
$dyear = intval(substr($dnow, 0, 4)); $dyear = intval(substr($dnow, 0, 4));
$dstart = substr($dnow, 0, 8) . '01'; $dstart = substr($dnow, 0, 8) . '01';
$dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5))); $dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5)));
$start_month = Temporal::utc($dstart, 'Y-m-d'); $start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
$end_month = Temporal::utc($dend, 'Y-m-d'); $end_month = DateTimeFormat::utc($dend, 'Y-m-d');
$str = day_translate(Temporal::utc($dnow, 'F')); $str = day_translate(DateTimeFormat::utc($dnow, 'F'));
if (!$ret[$dyear]) { if (!$ret[$dyear]) {
$ret[$dyear] = []; $ret[$dyear] = [];
} }
$ret[$dyear][] = [$str, $end_month, $start_month]; $ret[$dyear][] = [$str, $end_month, $start_month];
$dnow = Temporal::utc($dnow . ' -1 month', 'Y-m-d'); $dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
} }
return $ret; return $ret;
} }
@ -474,7 +466,7 @@ function posted_date_widget($url, $uid, $wall) {
return $o; return $o;
} }
$cutoff_year = intval(Temporal::localNow('Y')) - $visible_years; $cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
$cutoff = ((array_key_exists($cutoff_year, $ret))? true : false); $cutoff = ((array_key_exists($cutoff_year, $ret))? true : false);
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),[ $o = replace_macros(get_markup_template('posted_date_widget.tpl'),[

View file

@ -10,7 +10,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
/** /**
* @brief Calculate the hash that is needed for the "Friendica" cookie * @brief Calculate the hash that is needed for the "Friendica" cookie
@ -142,10 +142,10 @@ function authenticate_success($user_record, $login_initial = false, $interactive
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"'); header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
if ($login_initial || $login_refresh) { if ($login_initial || $login_refresh) {
dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user // Set the login date for all identities of the user
dba::update('user', ['login_date' => Temporal::utcNow()], dba::update('user', ['login_date' => DateTimeFormat::utcNow()],
['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]); ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
} }

View file

@ -15,8 +15,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\Term; use Friendica\Model\Term;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once "mod/proxy.php"; require_once "mod/proxy.php";
require_once "include/conversation.php"; require_once "include/conversation.php";
@ -723,7 +723,7 @@ function logger($msg, $level = 0) {
$callers = debug_backtrace(); $callers = debug_backtrace();
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
Temporal::utcNow(Temporal::ATOM), DateTimeFormat::utcNow(DateTimeFormat::ATOM),
$process_id, $process_id,
$LOGGER_LEVELS[$level], $LOGGER_LEVELS[$level],
basename($callers[0]['file']), basename($callers[0]['file']),
@ -789,7 +789,7 @@ function dlogger($msg, $level = 0) {
$callers = debug_backtrace(); $callers = debug_backtrace();
$logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n",
Temporal::utcNow(), DateTimeFormat::utcNow(),
$process_id, $process_id,
basename($callers[0]['file']), basename($callers[0]['file']),
$callers[0]['line'], $callers[0]['line'],

View file

@ -20,7 +20,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Login; use Friendica\Module\Login;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
require_once 'include/text.php'; require_once 'include/text.php';
@ -740,7 +740,7 @@ function admin_page_summary(App $a)
if (!$last_worker_call) { if (!$last_worker_call) {
$showwarning = true; $showwarning = true;
$warningtext[] = L10n::t('The worker was never executed. Please check your database structure!'); $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!');
} elseif ((strtotime(Temporal::utcNow()) - strtotime($last_worker_call)) > 60 * 60) { } elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) {
$showwarning = true; $showwarning = true;
$warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call); $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
} }

View file

@ -17,7 +17,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/event.php'; require_once 'include/event.php';
@ -152,8 +152,8 @@ function cal_content(App $a)
// The view mode part is similiar to /mod/events.php // The view mode part is similiar to /mod/events.php
if ($mode == 'view') { if ($mode == 'view') {
$thisyear = Temporal::localNow('Y'); $thisyear = DateTimeFormat::localNow('Y');
$thismonth = Temporal::localNow('m'); $thismonth = DateTimeFormat::localNow('m');
if (!$y) { if (!$y) {
$y = intval($thisyear); $y = intval($thisyear);
} }
@ -203,11 +203,11 @@ function cal_content(App $a)
} }
} }
$start = Temporal::utc($start); $start = DateTimeFormat::utc($start);
$finish = Temporal::utc($finish); $finish = DateTimeFormat::utc($finish);
$adjust_start = Temporal::local($start); $adjust_start = DateTimeFormat::local($start);
$adjust_finish = Temporal::local($finish); $adjust_finish = DateTimeFormat::local($finish);
// put the event parametes in an array so we can better transmit them // put the event parametes in an array so we can better transmit them
$event_params = [ $event_params = [
@ -231,7 +231,7 @@ function cal_content(App $a)
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach ($r as $rr) { foreach ($r as $rr) {
$j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
if (!x($links, $j)) { if (!x($links, $j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
} }

View file

@ -17,7 +17,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'mod/proxy.php'; require_once 'mod/proxy.php';
@ -540,7 +540,7 @@ function contacts_content(App $a)
$insecure = L10n::t('Private communications are not available for this contact.'); $insecure = L10n::t('Private communications are not available for this contact.');
$last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::local($contact['last-update'], 'D, j M Y, g:i A')); $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : DateTimeFormat::local($contact['last-update'], 'D, j M Y, g:i A'));
if ($contact['last-update'] > NULL_DATE) { if ($contact['last-update'] > NULL_DATE) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29")); $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29"));
@ -554,7 +554,7 @@ function contacts_content(App $a)
// tabs // tabs
$tab_str = contacts_tab($a, $contact_id, 2); $tab_str = contacts_tab($a, $contact_id, 2);
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < Temporal::utcNow()) ? L10n::t('Communications lost with this contact!') : ''); $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
$fetch_further_information = null; $fetch_further_information = null;
if ($contact['network'] == NETWORK_FEED) { if ($contact['network'] == NETWORK_FEED) {

View file

@ -31,8 +31,8 @@ use Friendica\Model\User;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
@ -327,8 +327,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
`network` = '%s' WHERE `id` = %d `network` = '%s' WHERE `id` = %d
", ",
intval($new_relation), intval($new_relation),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($duplex), intval($duplex),
intval($hidden), intval($hidden),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DFRN),
@ -378,8 +378,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
`rel` = %d `rel` = %d
WHERE `id` = %d WHERE `id` = %d
", ",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($addr), dbesc($addr),
dbesc($notify), dbesc($notify),
dbesc($poll), dbesc($poll),
@ -619,8 +619,8 @@ function dfrn_confirm_post(App $a, $handsfree = null)
`network` = '%s' WHERE `id` = %d `network` = '%s' WHERE `id` = %d
", ",
intval($new_relation), intval($new_relation),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($duplex), intval($duplex),
intval($forum), intval($forum),
intval($prv), intval($prv),

View file

@ -24,8 +24,8 @@ use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Login; use Friendica\Module\Login;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
@ -137,7 +137,7 @@ function dfrn_request_post(App $a)
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)", VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)",
intval(local_user()), intval(local_user()),
Temporal::utcNow(), DateTimeFormat::utcNow(),
dbesc($dfrn_url), dbesc($dfrn_url),
dbesc(normalise_link($dfrn_url)), dbesc(normalise_link($dfrn_url)),
$parms['addr'], $parms['addr'],
@ -241,7 +241,7 @@ function dfrn_request_post(App $a)
// Block friend request spam // Block friend request spam
if ($maxreq) { if ($maxreq) {
$r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d", $r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d",
dbesc(Temporal::utc('now - 24 hours')), dbesc(DateTimeFormat::utc('now - 24 hours')),
intval($uid) intval($uid)
); );
if (DBM::is_result($r) && count($r) > $maxreq) { if (DBM::is_result($r) && count($r) > $maxreq) {
@ -382,7 +382,7 @@ function dfrn_request_post(App $a)
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` ) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($uid), intval($uid),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
$parms['url'], $parms['url'],
dbesc(normalise_link($url)), dbesc(normalise_link($url)),
$parms['addr'], $parms['addr'],
@ -430,7 +430,7 @@ function dfrn_request_post(App $a)
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc(notags(trim($_POST['dfrn-request-message']))),
dbesc($hash), dbesc($hash),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
} }

View file

@ -12,7 +12,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -76,14 +76,14 @@ function events_post(App $a) {
} }
if ($adjust) { if ($adjust) {
$start = Temporal::convert($start, 'UTC', date_default_timezone_get()); $start = DateTimeFormat::convert($start, 'UTC', date_default_timezone_get());
if (! $nofinish) { if (! $nofinish) {
$finish = Temporal::convert($finish, 'UTC', date_default_timezone_get()); $finish = DateTimeFormat::convert($finish, 'UTC', date_default_timezone_get());
} }
} else { } else {
$start = Temporal::utc($start); $start = DateTimeFormat::utc($start);
if (! $nofinish) { if (! $nofinish) {
$finish = Temporal::utc($finish); $finish = DateTimeFormat::utc($finish);
} }
} }
@ -276,8 +276,8 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php // The view mode part is similiar to /mod/cal.php
if ($mode == 'view') { if ($mode == 'view') {
$thisyear = Temporal::localNow('Y'); $thisyear = DateTimeFormat::localNow('Y');
$thismonth = Temporal::localNow('m'); $thismonth = DateTimeFormat::localNow('m');
if (! $y) { if (! $y) {
$y = intval($thisyear); $y = intval($thisyear);
} }
@ -323,11 +323,11 @@ function events_content(App $a) {
} }
} }
$start = Temporal::utc($start); $start = DateTimeFormat::utc($start);
$finish = Temporal::utc($finish); $finish = DateTimeFormat::utc($finish);
$adjust_start = Temporal::local($start); $adjust_start = DateTimeFormat::local($start);
$adjust_finish = Temporal::local($finish); $adjust_finish = DateTimeFormat::local($finish);
// put the event parametes in an array so we can better transmit them // put the event parametes in an array so we can better transmit them
$event_params = [ $event_params = [
@ -351,7 +351,7 @@ function events_content(App $a) {
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
foreach ($r as $rr) { foreach ($r as $rr) {
$j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j');
if (! x($links,$j)) { if (! x($links,$j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
} }
@ -465,19 +465,19 @@ function events_content(App $a) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
} }
$syear = Temporal::convert($sdt, $tz, 'UTC', 'Y'); $syear = DateTimeFormat::convert($sdt, $tz, 'UTC', 'Y');
$smonth = Temporal::convert($sdt, $tz, 'UTC', 'm'); $smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm');
$sday = Temporal::convert($sdt, $tz, 'UTC', 'd'); $sday = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd');
$shour = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'H') : 0); $shour = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : 0);
$sminute = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'i') : 0); $sminute = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : 0);
$fyear = Temporal::convert($fdt, $tz, 'UTC', 'Y'); $fyear = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y');
$fmonth = Temporal::convert($fdt, $tz, 'UTC', 'm'); $fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm');
$fday = Temporal::convert($fdt, $tz, 'UTC', 'd'); $fday = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd');
$fhour = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'H') : 0); $fhour = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : 0);
$fminute = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'i') : 0); $fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : 0);
require_once 'include/acl_selectors.php' ; require_once 'include/acl_selectors.php' ;

View file

@ -7,7 +7,7 @@ use Friendica\App;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function fsuggest_post(App $a) function fsuggest_post(App $a)
{ {
@ -52,7 +52,7 @@ function fsuggest_post(App $a)
dbesc($r[0]['request']), dbesc($r[0]['request']),
dbesc($r[0]['photo']), dbesc($r[0]['photo']),
dbesc($hash), dbesc($hash),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
dbesc($hash), dbesc($hash),

View file

@ -12,7 +12,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function invite_post(App $a) function invite_post(App $a)
{ {
@ -62,7 +62,7 @@ function invite_post(App $a)
$r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ",
dbesc($code), dbesc($code),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
if (! is_site_admin()) { if (! is_site_admin()) {

View file

@ -28,8 +28,8 @@ use Friendica\Model\GContact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer; use Friendica\Util\Emailer;
use Friendica\Util\Temporal;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
require_once 'include/tags.php'; require_once 'include/tags.php';
@ -601,11 +601,11 @@ function item_post(App $a) {
$datarray['author-link'] = $author['url']; $datarray['author-link'] = $author['url'];
$datarray['author-avatar'] = $author['thumb']; $datarray['author-avatar'] = $author['thumb'];
$datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0); $datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0);
$datarray['created'] = Temporal::utcNow(); $datarray['created'] = DateTimeFormat::utcNow();
$datarray['edited'] = Temporal::utcNow(); $datarray['edited'] = DateTimeFormat::utcNow();
$datarray['commented'] = Temporal::utcNow(); $datarray['commented'] = DateTimeFormat::utcNow();
$datarray['received'] = Temporal::utcNow(); $datarray['received'] = DateTimeFormat::utcNow();
$datarray['changed'] = Temporal::utcNow(); $datarray['changed'] = DateTimeFormat::utcNow();
$datarray['extid'] = $extid; $datarray['extid'] = $extid;
$datarray['guid'] = $guid; $datarray['guid'] = $guid;
$datarray['uri'] = $uri; $datarray['uri'] = $uri;
@ -709,8 +709,8 @@ function item_post(App $a) {
'file' => $datarray['file'], 'file' => $datarray['file'],
'rendered-html' => $datarray['rendered-html'], 'rendered-html' => $datarray['rendered-html'],
'rendered-hash' => $datarray['rendered-hash'], 'rendered-hash' => $datarray['rendered-hash'],
'edited' => Temporal::utcNow(), 'edited' => DateTimeFormat::utcNow(),
'changed' => Temporal::utcNow()]; 'changed' => DateTimeFormat::utcNow()];
Item::update($fields, ['id' => $post_id]); Item::update($fields, ['id' => $post_id]);

View file

@ -20,7 +20,7 @@ function localtime_post(App $a)
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM $bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
if ($_POST['timezone']) { if ($_POST['timezone']) {
$a->data['mod-localtime'] = Temporal::convert($t, $_POST['timezone'], 'UTC', $bd_format); $a->data['mod-localtime'] = DateTimeFormat::convert($t, $_POST['timezone'], 'UTC', $bd_format);
} }
} }

View file

@ -8,7 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'boot.php'; require_once 'boot.php';
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -33,7 +33,7 @@ function lostpass_post(App $a)
$fields = [ $fields = [
'pwdreset' => $pwdreset_token, 'pwdreset' => $pwdreset_token,
'pwdreset_time' => Temporal::utcNow() 'pwdreset_time' => DateTimeFormat::utcNow()
]; ];
$result = dba::update('user', $fields, ['uid' => $user['uid']]); $result = dba::update('user', $fields, ['uid' => $user['uid']]);
if ($result) { if ($result) {
@ -92,7 +92,7 @@ function lostpass_content(App $a)
} }
// Password reset requests expire in 60 minutes // Password reset requests expire in 60 minutes
if ($user['pwdreset_time'] < Temporal::utc('now - 1 hour')) { if ($user['pwdreset_time'] < DateTimeFormat::utc('now - 1 hour')) {
$fields = [ $fields = [
'pwdreset' => null, 'pwdreset' => null,
'pwdreset_time' => null 'pwdreset_time' => null

View file

@ -11,7 +11,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Mail; use Friendica\Model\Mail;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/acl_selectors.php'; require_once 'include/acl_selectors.php';
require_once 'include/conversation.php'; require_once 'include/conversation.php';
@ -397,7 +397,7 @@ function message_content(App $a)
'body' => $body_e, 'body' => $body_e,
'delete' => L10n::t('Delete message'), 'delete' => L10n::t('Delete message'),
'to_name' => $to_name_e, 'to_name' => $to_name_e,
'date' => Temporal::local($message['created'], 'D, d M Y - g:i A'), 'date' => DateTimeFormat::local($message['created'], 'D, d M Y - g:i A'),
'ago' => relative_date($message['created']), 'ago' => relative_date($message['created']),
]; ];
@ -498,7 +498,7 @@ function render_messages(array $msg, $t)
'$delete' => L10n::t('Delete conversation'), '$delete' => L10n::t('Delete conversation'),
'$body' => $body_e, '$body' => $body_e,
'$to_name' => $to_name_e, '$to_name' => $to_name_e,
'$date' => Temporal::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')), '$date' => DateTimeFormat::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')),
'$ago' => relative_date($rr['mailcreated']), '$ago' => relative_date($rr['mailcreated']),
'$seen' => $rr['mailseen'], '$seen' => $rr['mailseen'],
'$count' => L10n::tt('%d message', '%d messages', $rr['count']), '$count' => L10n::tt('%d message', '%d messages', $rr['count']),

View file

@ -19,7 +19,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Module\Login; use Friendica\Module\Login;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/conversation.php'; require_once 'include/conversation.php';
require_once 'include/items.php'; require_once 'include/items.php';
@ -681,11 +681,11 @@ function networkThreadedView(App $a, $update = 0)
if ($datequery) { if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ",
dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get())))); dbesc(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
} }
if ($datequery2) { if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ",
dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get())))); dbesc(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
} }
$sql_order = ''; $sql_order = '';
@ -790,8 +790,8 @@ function networkThreadedView(App $a, $update = 0)
$top_limit = current($r)['order_date']; $top_limit = current($r)['order_date'];
$bottom_limit = end($r)['order_date']; $bottom_limit = end($r)['order_date'];
} else { } else {
$top_limit = Temporal::utcNow(); $top_limit = DateTimeFormat::utcNow();
$bottom_limit = Temporal::utcNow(); $bottom_limit = DateTimeFormat::utcNow();
} }
// When checking for updates we need to fetch from the newest date to the newest date before // When checking for updates we need to fetch from the newest date to the newest date before
@ -804,7 +804,7 @@ function networkThreadedView(App $a, $update = 0)
$top_limit = $last_date; $top_limit = $last_date;
} elseif ($a->pager['page'] == 1) { } elseif ($a->pager['page'] == 1) {
// Highest possible top limit when we are on the first page // Highest possible top limit when we are on the first page
$top_limit = Temporal::utcNow(); $top_limit = DateTimeFormat::utcNow();
} }
$items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item` $items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item`

View file

@ -20,8 +20,8 @@ use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/acl_selectors.php'; require_once 'include/acl_selectors.php';
@ -291,7 +291,7 @@ function photos_post(App $a)
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($rr['parent-uri']), dbesc($rr['parent-uri']),
intval($page_owner_uid) intval($page_owner_uid)
); );
@ -364,8 +364,8 @@ function photos_post(App $a)
); );
if (DBM::is_result($i)) { if (DBM::is_result($i)) {
q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($i[0]['uri']), dbesc($i[0]['uri']),
intval($page_owner_uid) intval($page_owner_uid)
); );
@ -402,7 +402,7 @@ function photos_post(App $a)
$resource_id = $a->argv[2]; $resource_id = $a->argv[2];
if (!strlen($albname)) { if (!strlen($albname)) {
$albname = Temporal::localNow('Y'); $albname = DateTimeFormat::localNow('Y');
} }
if (x($_POST,'rotate') !== false && if (x($_POST,'rotate') !== false &&
@ -649,8 +649,8 @@ function photos_post(App $a)
$r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($newtag), dbesc($newtag),
dbesc($newinform), dbesc($newinform),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($item_id), intval($item_id),
intval($page_owner_uid) intval($page_owner_uid)
); );
@ -738,7 +738,7 @@ function photos_post(App $a)
if (strlen($newalbum)) { if (strlen($newalbum)) {
$album = $newalbum; $album = $newalbum;
} else { } else {
$album = Temporal::localNow('Y'); $album = DateTimeFormat::localNow('Y');
} }
} }
@ -1361,7 +1361,7 @@ function photos_content(App $a)
$photo = [ $photo = [
'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> L10n::t('View Full Size'), 'title'=> L10n::t('View Full Size'),
'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::utcNow('ymdhis'), 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . DateTimeFormat::utcNow('ymdhis'),
'height' => $hires['height'], 'height' => $hires['height'],
'width' => $hires['width'], 'width' => $hires['width'],
'album' => $hires['album'], 'album' => $hires['album'],

View file

@ -14,7 +14,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -225,8 +225,8 @@ function ping_init(App $a)
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
ORDER BY `start` ASC ", ORDER BY `start` ASC ",
intval(local_user()), intval(local_user()),
dbesc(Temporal::utc('now + 7 days')), dbesc(DateTimeFormat::utc('now + 7 days')),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
if (DBM::is_result($ev)) { if (DBM::is_result($ev)) {
Cache::set($cachekey, $ev, CACHE_HOUR); Cache::set($cachekey, $ev, CACHE_HOUR);
@ -237,7 +237,7 @@ function ping_init(App $a)
$all_events = count($ev); $all_events = count($ev);
if ($all_events) { if ($all_events) {
$str_now = Temporal::timezoneNow($a->timezone, 'Y-m-d'); $str_now = DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d');
foreach ($ev as $x) { foreach ($ev as $x) {
$bd = false; $bd = false;
if ($x['type'] === 'birthday') { if ($x['type'] === 'birthday') {
@ -246,7 +246,7 @@ function ping_init(App $a)
} else { } else {
$events ++; $events ++;
} }
if (Temporal::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) {
$all_events_today ++; $all_events_today ++;
if ($bd) { if ($bd) {
$birthdays_today ++; $birthdays_today ++;
@ -362,7 +362,7 @@ function ping_init(App $a)
$notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO); $notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO);
} }
$local_time = Temporal::local($notif['date']); $local_time = DateTimeFormat::local($notif['date']);
$notifications[] = [ $notifications[] = [
'id' => $notif['id'], 'id' => $notif['id'],

View file

@ -3,13 +3,14 @@
// See here for a documentation for portable contacts: // See here for a documentation for portable contacts:
// https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
use Friendica\App; use Friendica\App;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function poco_init(App $a) { function poco_init(App $a) {
$system_mode = false; $system_mode = false;
@ -44,7 +45,7 @@ function poco_init(App $a) {
if ($a->argc > 1 && $a->argv[1] === '@global') { if ($a->argc > 1 && $a->argv[1] === '@global') {
// List of all profiles that this server recently had data from // List of all profiles that this server recently had data from
$global = true; $global = true;
$update_limit = date(Temporal::MYSQL, time() - 30 * 86400); $update_limit = date(DateTimeFormat::MYSQL, time() - 30 * 86400);
} }
if ($a->argc > 2 && $a->argv[2] === '@me') { if ($a->argc > 2 && $a->argv[2] === '@me') {
$justme = true; $justme = true;
@ -81,7 +82,7 @@ function poco_init(App $a) {
$sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid)); $sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid));
} }
if (x($_GET, 'updatedSince')) { if (x($_GET, 'updatedSince')) {
$update_limit = date(Temporal::MYSQL, strtotime($_GET['updatedSince'])); $update_limit = date(DateTimeFormat::MYSQL, strtotime($_GET['updatedSince']));
} }
if ($global) { if ($global) {
$contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')", $contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')",

View file

@ -16,7 +16,7 @@ use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Module\Login; use Friendica\Module\Login;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function profile_init(App $a) function profile_init(App $a)
{ {
@ -236,7 +236,7 @@ function profile_content(App $a, $update = 0)
if ($is_owner || !$last_updated) { if ($is_owner || !$last_updated) {
$sql_extra4 = " AND `item`.`unseen`"; $sql_extra4 = " AND `item`.`unseen`";
} else { } else {
$gmupdate = gmdate(Temporal::MYSQL, $last_updated); $gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
$sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'"; $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
} }
@ -272,10 +272,10 @@ function profile_content(App $a, $update = 0)
} }
if ($datequery) { if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get())))); $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get()))));
} }
if ($datequery2) { if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get())))); $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get()))));
} }
// Belongs the profile page to a forum? // Belongs the profile page to a forum?

View file

@ -12,7 +12,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function profile_photo_init(App $a) function profile_photo_init(App $a)
{ {
@ -130,7 +130,7 @@ function profile_photo_post(App $a) {
// so that browsers will do a cache update unconditionally // so that browsers will do a cache update unconditionally
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval(local_user()) intval(local_user())
); );
@ -230,7 +230,7 @@ function profile_photo_content(App $a) {
); );
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval(local_user()) intval(local_user())
); );

View file

@ -18,7 +18,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
function profiles_init(App $a) { function profiles_init(App $a) {
@ -220,9 +220,9 @@ function profiles_post(App $a) {
} }
if ($ignore_year) { if ($ignore_year) {
$dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d'); $dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
} else { } else {
$dob = Temporal::utc($dob, 'Y-m-d'); $dob = DateTimeFormat::utc($dob, 'Y-m-d');
} }
} }
@ -253,7 +253,7 @@ function profiles_post(App $a) {
if (! strlen($howlong)) { if (! strlen($howlong)) {
$howlong = NULL_DATE; $howlong = NULL_DATE;
} else { } else {
$howlong = Temporal::convert($howlong, 'UTC', date_default_timezone_get()); $howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get());
} }
// linkify the relationship target if applicable // linkify the relationship target if applicable
@ -488,7 +488,7 @@ function profiles_post(App $a) {
if ($namechanged && $is_default) { if ($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d", $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc($name), dbesc($name),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval(local_user()) intval(local_user())
); );
$r = q("UPDATE `user` set `username` = '%s' where `uid` = %d", $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
@ -725,7 +725,7 @@ function profiles_content(App $a) {
'$gender' => ContactSelector::gender($r[0]['gender']), '$gender' => ContactSelector::gender($r[0]['gender']),
'$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
'$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')], '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
'$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::local($r[0]['howlong']))], '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : DateTimeFormat::local($r[0]['howlong']))],
'$sexual' => ContactSelector::sexualPreference($r[0]['sexual']), '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
'$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']], '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
'$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")], '$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],

View file

@ -10,8 +10,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -188,7 +188,7 @@ function proxy_init(App $a) {
die(); die();
} }
$fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::utcNow(), 'edited' => Temporal::utcNow(), $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utcNow(),
'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image),
'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0,
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime]; 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime];

View file

@ -4,8 +4,8 @@ use Friendica\App;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
function post_var($name) { function post_var($name) {
return (x($_POST, $name)) ? notags(trim($_POST[$name])) : ''; return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
@ -139,7 +139,7 @@ function pubsubhubbub_init(App $a) {
dbesc($hub_callback)); dbesc($hub_callback));
if ($subscribe) { if ($subscribe) {
$last_update = Temporal::utcNow(); $last_update = DateTimeFormat::utcNow();
$push_flag = 0; $push_flag = 0;
// if we are just updating an old subscription, keep the // if we are just updating an old subscription, keep the

View file

@ -11,7 +11,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
@ -118,7 +118,7 @@ function register_post(App $a)
$hash = random_string(); $hash = random_string();
$r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ", $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ",
dbesc($hash), dbesc($hash),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($user['uid']), intval($user['uid']),
dbesc($result['password']), dbesc($result['password']),
dbesc($lang), dbesc($lang),

View file

@ -17,6 +17,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
@ -631,7 +632,7 @@ function settings_post(App $a)
if ($name_change) { if ($name_change) {
q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`", q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`",
dbesc($username), dbesc($username),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval(local_user()) intval(local_user())
); );
} }

View file

@ -14,7 +14,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/acl_selectors.php'; require_once 'include/acl_selectors.php';
@ -170,8 +170,8 @@ function videos_post(App $a) {
//echo "<pre>"; var_dump($i); killme(); //echo "<pre>"; var_dump($i); killme();
if (DBM::is_result($i)) { if (DBM::is_result($i)) {
q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($i[0]['uri']), dbesc($i[0]['uri']),
intval(local_user()) intval(local_user())
); );

View file

@ -7,8 +7,8 @@ use Friendica\App;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype; use Friendica\Util\Mimetype;
use Friendica\Util\Temporal;
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -124,7 +124,7 @@ function wall_attach_post(App $a) {
$filedata = @file_get_contents($src); $filedata = @file_get_contents($src);
$mimetype = Mimetype::getContentType($filename); $mimetype = Mimetype::getContentType($filename);
$hash = get_guid(64); $hash = get_guid(64);
$created = Temporal::utcNow(); $created = DateTimeFormat::utcNow();
$fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype, $fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created, 'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,

View file

@ -11,9 +11,9 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Temporal;
use dba; use dba;
use DOMDocument; use DOMDocument;
use DOMNode; use DOMNode;
@ -113,7 +113,7 @@ class OEmbed
'url' => normalise_link($embedurl), 'url' => normalise_link($embedurl),
'maxwidth' => $a->videowidth, 'maxwidth' => $a->videowidth,
'content' => $txt, 'content' => $txt,
'created' => Temporal::utcNow() 'created' => DateTimeFormat::utcNow()
], true); ], true);
} }

View file

@ -6,7 +6,7 @@ namespace Friendica\Core;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
use Memcache; use Memcache;
@ -147,7 +147,7 @@ class Cache
$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration)); $memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
return; return;
} }
$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::utcNow()]; $fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => DateTimeFormat::utcNow()];
$condition = ['k' => $key]; $condition = ['k' => $key];
dba::update('cache', $fields, $condition, true); dba::update('cache', $fields, $condition, true);
} }
@ -165,21 +165,21 @@ class Cache
if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) { if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
if ($max_level == CACHE_MONTH) { if ($max_level == CACHE_MONTH) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 30 days"), DateTimeFormat::utc("now - 30 days"),
CACHE_MONTH]; CACHE_MONTH];
dba::delete('cache', $condition); dba::delete('cache', $condition);
} }
if ($max_level <= CACHE_WEEK) { if ($max_level <= CACHE_WEEK) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 7 days"), DateTimeFormat::utc("now - 7 days"),
CACHE_WEEK]; CACHE_WEEK];
dba::delete('cache', $condition); dba::delete('cache', $condition);
} }
if ($max_level <= CACHE_DAY) { if ($max_level <= CACHE_DAY) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 1 days"), DateTimeFormat::utc("now - 1 days"),
CACHE_DAY]; CACHE_DAY];
dba::delete('cache', $condition); dba::delete('cache', $condition);
} }
@ -188,7 +188,7 @@ class Cache
if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) { if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 1 hours"), DateTimeFormat::utc("now - 1 hours"),
CACHE_HOUR]; CACHE_HOUR];
dba::delete('cache', $condition); dba::delete('cache', $condition);
@ -197,7 +197,7 @@ class Cache
if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) { if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 30 minutes"), DateTimeFormat::utc("now - 30 minutes"),
CACHE_HALF_HOUR]; CACHE_HALF_HOUR];
dba::delete('cache', $condition); dba::delete('cache', $condition);
@ -206,7 +206,7 @@ class Cache
if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) { if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 15 minutes"), DateTimeFormat::utc("now - 15 minutes"),
CACHE_QUARTER_HOUR]; CACHE_QUARTER_HOUR];
dba::delete('cache', $condition); dba::delete('cache', $condition);
@ -215,7 +215,7 @@ class Cache
if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) { if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 5 minutes"), DateTimeFormat::utc("now - 5 minutes"),
CACHE_FIVE_MINUTES]; CACHE_FIVE_MINUTES];
dba::delete('cache', $condition); dba::delete('cache', $condition);
@ -224,7 +224,7 @@ class Cache
if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) { if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
$condition = ["`updated` < ? AND `expire_mode` = ?", $condition = ["`updated` < ? AND `expire_mode` = ?",
Temporal::utc("now - 1 minutes"), DateTimeFormat::utc("now - 1 minutes"),
CACHE_MINUTE]; CACHE_MINUTE];
dba::delete('cache', $condition); dba::delete('cache', $condition);

View file

@ -13,8 +13,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Util\Temporal;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
@ -43,7 +43,7 @@ class NotificationsManager extends BaseObject
{ {
$rets = []; $rets = [];
foreach ($notes as $n) { foreach ($notes as $n) {
$local_time = Temporal::local($n['date']); $local_time = DateTimeFormat::local($n['date']);
$n['timestamp'] = strtotime($local_time); $n['timestamp'] = strtotime($local_time);
$n['date_rel'] = relative_date($n['date']); $n['date_rel'] = relative_date($n['date']);
$n['msg_html'] = bbcode($n['msg'], false, false, false, false); $n['msg_html'] = bbcode($n['msg'], false, false, false, false);
@ -244,7 +244,7 @@ class NotificationsManager extends BaseObject
$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO); $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['url']; $default_item_url = $it['url'];
$default_item_text = strip_tags(bbcode($it['msg'])); $default_item_text = strip_tags(bbcode($it['msg']));
$default_item_when = Temporal::local($it['date'], 'r'); $default_item_when = DateTimeFormat::local($it['date'], 'r');
$default_item_ago = relative_date($it['date']); $default_item_ago = relative_date($it['date']);
break; break;
@ -254,7 +254,7 @@ class NotificationsManager extends BaseObject
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO); $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
$default_item_url = $it['author-link']; $default_item_url = $it['author-link'];
$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']); $default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
$default_item_when = Temporal::local($it['created'], 'r'); $default_item_when = DateTimeFormat::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']); $default_item_ago = relative_date($it['created']);
break; break;
@ -266,7 +266,7 @@ class NotificationsManager extends BaseObject
$default_item_text = (($it['id'] == $it['parent']) $default_item_text = (($it['id'] == $it['parent'])
? L10n::t("%s created a new post", $it['author-name']) ? L10n::t("%s created a new post", $it['author-name'])
: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname'])); : L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
$default_item_when = Temporal::local($it['created'], 'r'); $default_item_when = DateTimeFormat::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']); $default_item_ago = relative_date($it['created']);
} }

View file

@ -9,10 +9,9 @@ use Friendica\Core\Config;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Process; use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Lock; use Friendica\Util\Lock;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -235,7 +234,7 @@ class Worker
if ($age > 1) { if ($age > 1) {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]); dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
self::$db_duration += (microtime(true) - $stamp); self::$db_duration += (microtime(true) - $stamp);
} }
@ -245,7 +244,7 @@ class Worker
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) { if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
Config::set('system', 'last_poller_execution', Temporal::utcNow()); Config::set('system', 'last_poller_execution', DateTimeFormat::utcNow());
} }
self::$db_duration = (microtime(true) - $stamp); self::$db_duration = (microtime(true) - $stamp);
@ -278,7 +277,7 @@ class Worker
if ($age > 1) { if ($age > 1) {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]); dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
self::$db_duration += (microtime(true) - $stamp); self::$db_duration += (microtime(true) - $stamp);
} }
@ -286,7 +285,7 @@ class Worker
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) { if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
Config::set('system', 'last_poller_execution', Temporal::utcNow()); Config::set('system', 'last_poller_execution', DateTimeFormat::utcNow());
} }
self::$db_duration = (microtime(true) - $stamp); self::$db_duration = (microtime(true) - $stamp);
} else { } else {
@ -574,7 +573,7 @@ class Worker
} }
dba::update( dba::update(
'workerqueue', 'workerqueue',
['executed' => NULL_DATE, 'created' => Temporal::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['executed' => NULL_DATE, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
['id' => $entry["id"]] ['id' => $entry["id"]]
); );
} else { } else {
@ -825,7 +824,7 @@ class Worker
if ($found) { if ($found) {
$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`"; $condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
array_unshift($ids, $condition); array_unshift($ids, $condition);
dba::update('workerqueue', ['executed' => Temporal::utcNow(), 'pid' => $mypid], $ids); dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow(), 'pid' => $mypid], $ids);
} }
return $found; return $found;
@ -953,7 +952,7 @@ class Worker
/// @todo We should clean up the corresponding workerqueue entries as well /// @todo We should clean up the corresponding workerqueue entries as well
$condition = ["`created` < ? AND `command` = 'worker.php'", $condition = ["`created` < ? AND `command` = 'worker.php'",
Temporal::utc("now - ".$timeout." minutes")]; DateTimeFormat::utc("now - ".$timeout." minutes")];
dba::delete('process', $condition); dba::delete('process', $condition);
} }
@ -1040,7 +1039,7 @@ class Worker
$priority = PRIORITY_MEDIUM; $priority = PRIORITY_MEDIUM;
$dont_fork = Config::get("system", "worker_dont_fork"); $dont_fork = Config::get("system", "worker_dont_fork");
$created = Temporal::utcNow(); $created = DateTimeFormat::utcNow();
if (is_int($run_parameter)) { if (is_int($run_parameter)) {
$priority = $run_parameter; $priority = $run_parameter;

View file

@ -5,7 +5,7 @@
namespace Friendica\Database; namespace Friendica\Database;
use dba; use dba;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -127,6 +127,6 @@ class DBM
$timestamp = -62135596800; $timestamp = -62135596800;
} }
return date(Temporal::MYSQL, (int)$timestamp); return date(DateTimeFormat::MYSQL, (int)$timestamp);
} }
} }

View file

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

View file

@ -14,8 +14,8 @@ use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
use Exception; use Exception;
@ -120,12 +120,12 @@ class GContact
intval($uid), intval($uid),
intval($gcid), intval($gcid),
intval($zcid), intval($zcid),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
} else { } else {
q( q(
"UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d", "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($cid),
intval($uid), intval($uid),
intval($gcid), intval($gcid),
@ -717,8 +717,8 @@ class GContact
dbesc($contact["url"]), dbesc($contact["url"]),
dbesc(normalise_link($contact["url"])), dbesc(normalise_link($contact["url"])),
dbesc($contact["photo"]), dbesc($contact["photo"]),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($contact["location"]), dbesc($contact["location"]),
dbesc($contact["about"]), dbesc($contact["about"]),
intval($contact["hide"]), intval($contact["hide"]),
@ -1050,7 +1050,7 @@ class GContact
foreach ($r as $server) { foreach ($r as $server) {
self::fetchGsUsers($server["url"]); 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\Object\Image;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use dba; use dba;
use Text_LanguageDetect; use Text_LanguageDetect;
@ -149,7 +150,7 @@ class Item extends BaseObject
// Set the item to "deleted" // Set the item to "deleted"
dba::update('item', ['deleted' => true, 'title' => '', 'body' => '', dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()], 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
['id' => $item['id']]); ['id' => $item['id']]);
create_tags_from_item($item['id']); create_tags_from_item($item['id']);

View file

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

View file

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

View file

@ -5,7 +5,7 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject; use Friendica\BaseObject;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -34,7 +34,7 @@ class Process extends BaseObject
dba::transaction(); dba::transaction();
if (!dba::exists('process', ['pid' => $pid])) { 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(); dba::commit();

View file

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

View file

@ -6,7 +6,7 @@ namespace Friendica\Model;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -20,7 +20,7 @@ class Queue
public static function updateTime($id) public static function updateTime($id)
{ {
logger('queue: requeue item ' . $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\Model\Photo;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
use Exception; use Exception;
use LightOpenID; use LightOpenID;
@ -396,7 +396,7 @@ class User
'verified' => $verified, 'verified' => $verified,
'blocked' => $blocked, 'blocked' => $blocked,
'timezone' => 'UTC', 'timezone' => 'UTC',
'register_date' => Temporal::utcNow(), 'register_date' => DateTimeFormat::utcNow(),
'default-location' => '' 'default-location' => ''
]); ]);
@ -613,7 +613,7 @@ class User
dba::insert('userd', ['username' => $user['nickname']]); dba::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php) // 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); Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory // Send an update to the directory

View file

@ -10,8 +10,8 @@ use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
use Exception; use Exception;
use LightOpenID; use LightOpenID;
@ -121,7 +121,7 @@ class Login extends BaseModule
// if we haven't failed up this point, log them in. // if we haven't failed up this point, log them in.
$_SESSION['remember'] = $_POST['remember']; $_SESSION['remember'] = $_POST['remember'];
$_SESSION['last_login_date'] = Temporal::utcNow(); $_SESSION['last_login_date'] = DateTimeFormat::utcNow();
authenticate_success($record, true, true); authenticate_success($record, true, true);
if (x($_SESSION, 'return_url')) { if (x($_SESSION, 'return_url')) {
@ -220,10 +220,10 @@ class Login extends BaseModule
// stays logged in for a long time, e.g. with "Remember Me" // stays logged in for a long time, e.g. with "Remember Me"
$login_refresh = false; $login_refresh = false;
if (!x($_SESSION['last_login_date'])) { if (!x($_SESSION['last_login_date'])) {
$_SESSION['last_login_date'] = Temporal::utcNow(); $_SESSION['last_login_date'] = DateTimeFormat::utcNow();
} }
if (strcmp(Temporal::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) { if (strcmp(DateTimeFormat::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
$_SESSION['last_login_date'] = Temporal::utcNow(); $_SESSION['last_login_date'] = DateTimeFormat::utcNow();
$login_refresh = true; $login_refresh = true;
} }
authenticate_success($user, false, false, $login_refresh); authenticate_success($user, false, false, $login_refresh);

View file

@ -9,7 +9,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Network\FKOAuthDataStore; use Friendica\Network\FKOAuthDataStore;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
use OAuthServer; use OAuthServer;
use OAuthSignatureMethod_HMAC_SHA1; use OAuthSignatureMethod_HMAC_SHA1;
@ -68,7 +68,7 @@ class FKOAuth1 extends OAuthServer
$_SESSION['cid'] = $a->cid; $_SESSION['cid'] = $a->cid;
} }
dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
Addon::callHooks('logged_in', $a->user); Addon::callHooks('logged_in', $a->user);
} }

View file

@ -13,7 +13,7 @@ use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -124,7 +124,7 @@ class Post extends BaseObject
if (strtotime($item['edited']) - strtotime($item['created']) > 1) { if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
$edited = [ $edited = [
'label' => L10n::t('This entry was edited'), 'label' => L10n::t('This entry was edited'),
'date' => Temporal::local($item['edited'], 'r'), 'date' => DateTimeFormat::local($item['edited'], 'r'),
'relative' => relative_date($item['edited']) 'relative' => relative_date($item['edited'])
]; ];
} }
@ -301,7 +301,7 @@ class Post extends BaseObject
$comment = $this->getCommentBox($indent); $comment = $this->getCommentBox($indent);
if (strcmp(Temporal::utc($item['created']), Temporal::utc('now - 12 hours')) > 0) { if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
$shiny = 'shiny'; $shiny = 'shiny';
} }
@ -364,7 +364,7 @@ class Post extends BaseObject
'osparkle' => $osparkle, 'osparkle' => $osparkle,
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'title' => $title_e, 'title' => $title_e,
'localtime' => Temporal::local($item['created'], 'r'), 'localtime' => DateTimeFormat::local($item['created'], 'r'),
'ago' => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']), 'ago' => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']),
'app' => $item['app'], 'app' => $item['app'],
'created' => relative_date($item['created']), 'created' => relative_date($item['created']),

View file

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

View file

@ -9,12 +9,11 @@
*/ */
namespace Friendica\Protocol; namespace Friendica\Protocol;
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -26,8 +25,8 @@ use Friendica\Model\Queue;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
use SimpleXMLElement; use SimpleXMLElement;
@ -77,7 +76,7 @@ class Diaspora
$r = q( $r = q(
"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`) "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')", VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
Temporal::utcNow(), DateTimeFormat::utcNow(),
dbesc($addr), dbesc($addr),
dbesc($addr), dbesc($addr),
dbesc($server), dbesc($server),
@ -85,9 +84,9 @@ class Diaspora
dbesc($batch), dbesc($batch),
dbesc(NETWORK_DIASPORA), dbesc(NETWORK_DIASPORA),
intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FOLLOWER),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch)); $relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
@ -871,7 +870,7 @@ class Diaspora
dbesc($arr["confirm"]), dbesc($arr["confirm"]),
dbesc($arr["alias"]), dbesc($arr["alias"]),
dbesc($arr["pubkey"]), dbesc($arr["pubkey"]),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($arr["url"]), dbesc($arr["url"]),
dbesc($arr["network"]) dbesc($arr["network"])
); );
@ -894,7 +893,7 @@ class Diaspora
dbesc($arr["network"]), dbesc($arr["network"]),
dbesc($arr["alias"]), dbesc($arr["alias"]),
dbesc($arr["pubkey"]), dbesc($arr["pubkey"]),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
} }
@ -1654,9 +1653,9 @@ class Diaspora
$text = unxmlify($data->text); $text = unxmlify($data->text);
if (isset($data->created_at)) { if (isset($data->created_at)) {
$created_at = Temporal::utc(notags(unxmlify($data->created_at))); $created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
} else { } else {
$created_at = Temporal::utcNow(); $created_at = DateTimeFormat::utcNow();
} }
if (isset($data->thread_parent_guid)) { if (isset($data->thread_parent_guid)) {
@ -1786,7 +1785,7 @@ class Diaspora
$msg_guid = notags(unxmlify($mesg->guid)); $msg_guid = notags(unxmlify($mesg->guid));
$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid)); $msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
$msg_text = unxmlify($mesg->text); $msg_text = unxmlify($mesg->text);
$msg_created_at = Temporal::utc(notags(unxmlify($mesg->created_at))); $msg_created_at = DateTimeFormat::utc(notags(unxmlify($mesg->created_at)));
if ($msg_conversation_guid != $guid) { if ($msg_conversation_guid != $guid) {
logger("message conversation guid does not belong to the current conversation."); logger("message conversation guid does not belong to the current conversation.");
@ -1831,7 +1830,7 @@ class Diaspora
dba::unlock(); dba::unlock();
dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]); dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
notification( notification(
[ [
@ -1865,7 +1864,7 @@ class Diaspora
$author = notags(unxmlify($data->author)); $author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid)); $guid = notags(unxmlify($data->guid));
$subject = notags(unxmlify($data->subject)); $subject = notags(unxmlify($data->subject));
$created_at = Temporal::utc(notags(unxmlify($data->created_at))); $created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
$participants = notags(unxmlify($data->participants)); $participants = notags(unxmlify($data->participants));
$messages = $data->message; $messages = $data->message;
@ -1897,7 +1896,7 @@ class Diaspora
dbesc($guid), dbesc($guid),
dbesc($author), dbesc($author),
dbesc($created_at), dbesc($created_at),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($subject), dbesc($subject),
dbesc($participants) dbesc($participants)
); );
@ -2098,7 +2097,7 @@ class Diaspora
$guid = notags(unxmlify($data->guid)); $guid = notags(unxmlify($data->guid));
$conversation_guid = notags(unxmlify($data->conversation_guid)); $conversation_guid = notags(unxmlify($data->conversation_guid));
$text = unxmlify($data->text); $text = unxmlify($data->text);
$created_at = Temporal::utc(notags(unxmlify($data->created_at))); $created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
$contact = self::allowedContactByHandle($importer, $author, true); $contact = self::allowedContactByHandle($importer, $author, true);
if (!$contact) { if (!$contact) {
@ -2164,7 +2163,7 @@ class Diaspora
dba::unlock(); dba::unlock();
dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]); dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
return true; return true;
} }
@ -2315,7 +2314,7 @@ class Diaspora
$birthday = str_replace("1000", "1901", $birthday); $birthday = str_replace("1000", "1901", $birthday);
if ($birthday != "") { if ($birthday != "") {
$birthday = Temporal::utc($birthday, "Y-m-d"); $birthday = DateTimeFormat::utc($birthday, "Y-m-d");
} }
// this is to prevent multiple birthday notifications in a single year // this is to prevent multiple birthday notifications in a single year
@ -2331,7 +2330,7 @@ class Diaspora
dbesc($name), dbesc($name),
dbesc($nick), dbesc($nick),
dbesc($author), dbesc($author),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc($birthday), dbesc($birthday),
dbesc($location), dbesc($location),
dbesc($about), dbesc($about),
@ -2537,7 +2536,7 @@ class Diaspora
intval($importer["uid"]), intval($importer["uid"]),
dbesc($ret["network"]), dbesc($ret["network"]),
dbesc($ret["addr"]), dbesc($ret["addr"]),
Temporal::utcNow(), DateTimeFormat::utcNow(),
dbesc($ret["url"]), dbesc($ret["url"]),
dbesc(normalise_link($ret["url"])), dbesc(normalise_link($ret["url"])),
dbesc($batch), dbesc($batch),
@ -2580,7 +2579,7 @@ class Diaspora
0, 0,
dbesc(L10n::t("Sharing notification from Diaspora network")), dbesc(L10n::t("Sharing notification from Diaspora network")),
dbesc($hash), dbesc($hash),
dbesc(Temporal::utcNow()) dbesc(DateTimeFormat::utcNow())
); );
} else { } else {
// automatic friend approval // automatic friend approval
@ -2611,8 +2610,8 @@ class Diaspora
WHERE `id` = %d WHERE `id` = %d
", ",
intval($new_relation), intval($new_relation),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
dbesc(Temporal::utcNow()), dbesc(DateTimeFormat::utcNow()),
intval($contact_record["id"]) intval($contact_record["id"])
); );
@ -2716,7 +2715,7 @@ class Diaspora
{ {
$author = notags(unxmlify($data->author)); $author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid)); $guid = notags(unxmlify($data->guid));
$created_at = Temporal::utc(notags(unxmlify($data->created_at))); $created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
$root_author = notags(unxmlify($data->root_author)); $root_author = notags(unxmlify($data->root_author));
$root_guid = notags(unxmlify($data->root_guid)); $root_guid = notags(unxmlify($data->root_guid));
/// @todo handle unprocessed property "provider_display_name" /// @todo handle unprocessed property "provider_display_name"
@ -2852,8 +2851,8 @@ class Diaspora
'deleted' => true, 'deleted' => true,
'title' => '', 'title' => '',
'body' => '', 'body' => '',
'edited' => Temporal::utcNow(), 'edited' => DateTimeFormat::utcNow(),
'changed' => Temporal::utcNow()], 'changed' => DateTimeFormat::utcNow()],
['id' => $item["id"]] ['id' => $item["id"]]
); );
@ -2930,7 +2929,7 @@ class Diaspora
{ {
$author = notags(unxmlify($data->author)); $author = notags(unxmlify($data->author));
$guid = notags(unxmlify($data->guid)); $guid = notags(unxmlify($data->guid));
$created_at = Temporal::utc(notags(unxmlify($data->created_at))); $created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
$public = notags(unxmlify($data->public)); $public = notags(unxmlify($data->public));
$text = unxmlify($data->text); $text = unxmlify($data->text);
$provider_display_name = notags(unxmlify($data->provider_display_name)); $provider_display_name = notags(unxmlify($data->provider_display_name));
@ -3593,7 +3592,7 @@ class Diaspora
$eventdata['guid'] = $event['guid']; $eventdata['guid'] = $event['guid'];
} }
$mask = Temporal::ATOM; $mask = DateTimeFormat::ATOM;
/// @todo - establish "all day" events in Friendica /// @todo - establish "all day" events in Friendica
$eventdata["all_day"] = "false"; $eventdata["all_day"] = "false";
@ -3607,10 +3606,10 @@ class Diaspora
} }
if ($event['start']) { if ($event['start']) {
$eventdata['start'] = Temporal::convert($event['start'], "UTC", $eventdata['timezone'], $mask); $eventdata['start'] = DateTimeFormat::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
} }
if ($event['finish'] && !$event['nofinish']) { if ($event['finish'] && !$event['nofinish']) {
$eventdata['end'] = Temporal::convert($event['finish'], "UTC", $eventdata['timezone'], $mask); $eventdata['end'] = DateTimeFormat::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
} }
if ($event['summary']) { if ($event['summary']) {
$eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary'])); $eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary']));
@ -3652,7 +3651,7 @@ class Diaspora
$public = (($item["private"]) ? "false" : "true"); $public = (($item["private"]) ? "false" : "true");
$created = Temporal::utc($item["created"], Temporal::ATOM); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
// Detect a share element and do a reshare // Detect a share element and do a reshare
if (!$item['private'] && ($ret = self::isReshare($item["body"]))) { if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
@ -3855,7 +3854,7 @@ class Diaspora
$parent = $p[0]; $parent = $p[0];
$text = html_entity_decode(bb2diaspora($item["body"])); $text = html_entity_decode(bb2diaspora($item["body"]));
$created = Temporal::utc($item["created"], Temporal::ATOM); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
$comment = ["author" => self::myHandle($owner), $comment = ["author" => self::myHandle($owner),
"guid" => $item["guid"], "guid" => $item["guid"],
@ -4086,12 +4085,12 @@ class Diaspora
"author" => $cnv["creator"], "author" => $cnv["creator"],
"guid" => $cnv["guid"], "guid" => $cnv["guid"],
"subject" => $cnv["subject"], "subject" => $cnv["subject"],
"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM), "created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
"participants" => $cnv["recips"] "participants" => $cnv["recips"]
]; ];
$body = bb2diaspora($item["body"]); $body = bb2diaspora($item["body"]);
$created = Temporal::utc($item["created"], Temporal::ATOM); $created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
$msg = [ $msg = [
"author" => $myaddr, "author" => $myaddr,
@ -4109,7 +4108,7 @@ class Diaspora
"author" => $cnv["creator"], "author" => $cnv["creator"],
"guid" => $cnv["guid"], "guid" => $cnv["guid"],
"subject" => $cnv["subject"], "subject" => $cnv["subject"],
"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM), "created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
"participants" => $cnv["recips"], "participants" => $cnv["recips"],
"message" => $msg]; "message" => $msg];
@ -4217,7 +4216,7 @@ class Diaspora
if ($year < 1004) { if ($year < 1004) {
$year = 1004; $year = 1004;
} }
$dob = Temporal::utc($year . '-' . $month . '-'. $day, 'Y-m-d'); $dob = DateTimeFormat::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
} }
$about = $profile['about']; $about = $profile['about'];

View file

@ -16,9 +16,9 @@ use Friendica\Model\GContact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Lock; use Friendica\Util\Lock;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
use dba; use dba;
use DOMDocument; use DOMDocument;
@ -199,7 +199,7 @@ class OStatus
$contact["location"] = $value; $contact["location"] = $value;
} }
$contact['name-date'] = Temporal::utcNow(); $contact['name-date'] = DateTimeFormat::utcNow();
dba::update('contact', $contact, ['id' => $contact["id"]], $current); dba::update('contact', $contact, ['id' => $contact["id"]], $current);
@ -220,7 +220,7 @@ class OStatus
'nurl' => normalise_link($author["author-link"]), 'nurl' => normalise_link($author["author-link"]),
'nick' => $contact["nick"], 'alias' => $contact["alias"], 'nick' => $contact["nick"], 'alias' => $contact["alias"],
'about' => $contact["about"], 'location' => $contact["location"], 'about' => $contact["about"], 'location' => $contact["location"],
'success_update' => Temporal::utcNow(), 'last-update' => Temporal::utcNow()]; 'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
dba::update('contact', $fields, ['id' => $cid], $old_contact); dba::update('contact', $fields, ['id' => $cid], $old_contact);
@ -558,7 +558,7 @@ class OStatus
dba::update( dba::update(
'item', 'item',
['deleted' => true, 'title' => '', 'body' => '', ['deleted' => true, 'title' => '', 'body' => '',
'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()], 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
['id' => $deleted["id"]] ['id' => $deleted["id"]]
); );
@ -1273,7 +1273,7 @@ class OStatus
XML::addElement($doc, $root, "title", $title); 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, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
XML::addElement($doc, $root, "logo", $owner["photo"]); XML::addElement($doc, $root, "logo", $owner["photo"]);
XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM)); XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
$author = self::addAuthor($doc, $owner); $author = self::addAuthor($doc, $owner);
$root->appendChild($author); $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" => "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, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
XML::addElement($doc, $source, "icon", $contact["photo"]); XML::addElement($doc, $source, "icon", $contact["photo"]);
XML::addElement($doc, $source, "updated", Temporal::utc($contact["success_update"]."+00:00", Temporal::ATOM)); XML::addElement($doc, $source, "updated", DateTimeFormat::utc($contact["success_update"]."+00:00", DateTimeFormat::ATOM));
return $source; return $source;
} }
@ -1923,8 +1923,8 @@ class OStatus
XML::addElement($doc, $entry, "activity:verb", $verb); XML::addElement($doc, $entry, "activity:verb", $verb);
XML::addElement($doc, $entry, "published", Temporal::utc($item["created"]."+00:00", Temporal::ATOM)); XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM));
XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"]."+00:00", Temporal::ATOM)); XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM));
} }
/** /**
@ -2127,7 +2127,7 @@ class OStatus
$last_update = 'now -30 days'; $last_update = 'now -30 days';
} }
$check_date = Temporal::utc($last_update); $check_date = DateTimeFormat::utc($last_update);
$authorid = Contact::getIdForURL($owner["url"], 0); $authorid = Contact::getIdForURL($owner["url"], 0);
$sql_extra = ''; $sql_extra = '';

View file

@ -15,8 +15,8 @@ use Friendica\Database\DBM;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
@ -144,7 +144,7 @@ class PortableContact
} }
if (isset($entry->updated)) { if (isset($entry->updated)) {
$updated = date(Temporal::MYSQL, strtotime($entry->updated)); $updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
} }
if (isset($entry->network)) { if (isset($entry->network)) {
@ -315,7 +315,7 @@ class PortableContact
$contact = ["url" => $profile]; $contact = ["url" => $profile];
if ($gcontacts[0]["created"] <= NULL_DATE) { if ($gcontacts[0]["created"] <= NULL_DATE) {
$contact['created'] = Temporal::utcNow(); $contact['created'] = DateTimeFormat::utcNow();
} }
if ($force) { if ($force) {
@ -338,7 +338,7 @@ class PortableContact
if ($server_url != "") { if ($server_url != "") {
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) { if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
if ($force) { if ($force) {
$fields = ['last_failure' => Temporal::utcNow()]; $fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
} }
@ -412,14 +412,14 @@ class PortableContact
// Set the date of the last contact // Set the date of the last contact
/// @todo By now the function "update_gcontact" doesn't work with this field /// @todo By now the function "update_gcontact" doesn't work with this field
//$contact["last_contact"] = Temporal::utcNow(); //$contact["last_contact"] = DateTimeFormat::utcNow();
$contact = array_merge($contact, $noscrape); $contact = array_merge($contact, $noscrape);
GContact::update($contact); GContact::update($contact);
if (trim($noscrape["updated"]) != "") { if (trim($noscrape["updated"]) != "") {
$fields = ['last_contact' => Temporal::utcNow()]; $fields = ['last_contact' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG); logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@ -468,7 +468,7 @@ class PortableContact
} }
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) { if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
$fields = ['last_failure' => Temporal::utcNow()]; $fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG); logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
@ -484,7 +484,7 @@ class PortableContact
$feedret = Network::curl($data["poll"]); $feedret = Network::curl($data["poll"]);
if (!$feedret["success"]) { if (!$feedret["success"]) {
$fields = ['last_failure' => Temporal::utcNow()]; $fields = ['last_failure' => DateTimeFormat::utcNow()];
dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]); dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG); logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
@ -533,7 +533,7 @@ class PortableContact
public static function updateNeeded($created, $updated, $last_failure, $last_contact) public static function updateNeeded($created, $updated, $last_failure, $last_contact)
{ {
$now = strtotime(Temporal::utcNow()); $now = strtotime(DateTimeFormat::utcNow());
if ($updated > $last_contact) { if ($updated > $last_contact) {
$contact_time = strtotime($updated); $contact_time = strtotime($updated);
@ -922,7 +922,7 @@ class PortableContact
$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]); $gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
if (DBM::is_result($gserver)) { if (DBM::is_result($gserver)) {
if ($gserver["created"] <= NULL_DATE) { if ($gserver["created"] <= NULL_DATE) {
$fields = ['created' => Temporal::utcNow()]; $fields = ['created' => DateTimeFormat::utcNow()];
$condition = ['nurl' => normalise_link($server_url)]; $condition = ['nurl' => normalise_link($server_url)];
dba::update('gserver', $fields, $condition); dba::update('gserver', $fields, $condition);
} }
@ -969,7 +969,7 @@ class PortableContact
// Mastodon uses the "@" for user profiles. // Mastodon uses the "@" for user profiles.
// But this can be misunderstood. // But this can be misunderstood.
if (parse_url($server_url, PHP_URL_USER) != '') { if (parse_url($server_url, PHP_URL_USER) != '') {
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false; return false;
} }
@ -985,7 +985,7 @@ class PortableContact
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) && if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) { ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false; return false;
} }
@ -1000,7 +1000,7 @@ class PortableContact
// Quit if there is a timeout // Quit if there is a timeout
if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG); logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]); dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false; return false;
} }
@ -1332,9 +1332,9 @@ class PortableContact
if ($failure) { if ($failure) {
$last_contact = $orig_last_contact; $last_contact = $orig_last_contact;
$last_failure = Temporal::utcNow(); $last_failure = DateTimeFormat::utcNow();
} else { } else {
$last_contact = Temporal::utcNow(); $last_contact = DateTimeFormat::utcNow();
$last_failure = $orig_last_failure; $last_failure = $orig_last_failure;
} }
@ -1362,7 +1362,7 @@ class PortableContact
dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]); dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
} elseif (!$failure) { } elseif (!$failure) {
$fields['nurl'] = normalise_link($server_url); $fields['nurl'] = normalise_link($server_url);
$fields['created'] = Temporal::utcNow(); $fields['created'] = DateTimeFormat::utcNow();
dba::insert('gserver', $fields); dba::insert('gserver', $fields);
} }
logger("End discovery for server " . $server_url, LOGGER_DEBUG); logger("End discovery for server " . $server_url, LOGGER_DEBUG);
@ -1507,7 +1507,7 @@ class PortableContact
$timeframe = 30; $timeframe = 30;
} }
$updatedSince = date(Temporal::MYSQL, time() - $timeframe * 86400); $updatedSince = date(DateTimeFormat::MYSQL, time() - $timeframe * 86400);
// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3) // Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
$url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; $url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
@ -1526,7 +1526,7 @@ class PortableContact
} }
} }
$fields = ['last_poco_query' => Temporal::utcNow()]; $fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return true; return true;
@ -1535,7 +1535,7 @@ class PortableContact
self::checkServer($server["url"], $server["network"], true); self::checkServer($server["url"], $server["network"], true);
// If we couldn't reach the server, we will try it some time later // If we couldn't reach the server, we will try it some time later
$fields = ['last_poco_query' => Temporal::utcNow()]; $fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return false; return false;
@ -1561,7 +1561,7 @@ class PortableContact
foreach ($r as $server) { foreach ($r as $server) {
if (!self::checkServer($server["url"], $server["network"])) { if (!self::checkServer($server["url"], $server["network"])) {
// The server is not reachable? Okay, then we will try it later // The server is not reachable? Okay, then we will try it later
$fields = ['last_poco_query' => Temporal::utcNow()]; $fields = ['last_poco_query' => DateTimeFormat::utcNow()];
dba::update('gserver', $fields, ['nurl' => $server["nurl"]]); dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
continue; continue;
} }
@ -1654,7 +1654,7 @@ class PortableContact
} }
if (isset($entry->updated)) { if (isset($entry->updated)) {
$updated = date(Temporal::MYSQL, strtotime($entry->updated)); $updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
} }
if (isset($entry->network)) { if (isset($entry->network)) {

139
src/Util/DateTimeFormat.php Normal file
View file

@ -0,0 +1,139 @@
<?php
/**
* @file src/Util/DateTimeFormat.php
*/
namespace Friendica\Util;
use DateTime;
use DateTimeZone;
use Exception;
/**
* @brief Temporal class
*/
class DateTimeFormat
{
const ATOM = 'Y-m-d\TH:i:s\Z';
const MYSQL = 'Y-m-d H:i:s';
/**
* 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 local.
*
* @param string $time A date/time string
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function local($time, $format = self::MYSQL)
{
return self::convert($time, date_default_timezone_get(), 'UTC', $format);
}
/**
* convert() shorthand for timezoned now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function timezoneNow($timezone, $format = self::MYSQL)
{
return self::convert('now', $timezone, 'UTC', $format);
}
/**
* convert() shorthand for local now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function localNow($format = self::MYSQL)
{
return self::local('now', $format);
}
/**
* convert() shorthand for UTC now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function utcNow($format = self::MYSQL)
{
return self::utc('now', $format);
}
/**
* @brief General purpose date parse/convert/format function.
*
* @param string $s Some parseable date/time string
* @param string $tz_to Destination timezone
* @param string $tz_from Source timezone
* @param string $format Output format recognised from php's DateTime class
* http://www.php.net/manual/en/datetime.format.php
*
* @return string Formatted date according to given format
*/
public static function convert($s = 'now', $tz_to = 'UTC', $tz_from = 'UTC', $format = self::MYSQL)
{
// Defaults to UTC if nothing is set, but throws an exception if set to empty string.
// Provide some sane defaults regardless.
if ($from === '') {
$from = 'UTC';
}
if ($to === '') {
$to = 'UTC';
}
if (($s === '') || (!is_string($s))) {
$s = 'now';
}
/*
* Slight hackish adjustment so that 'zero' datetime actually returns what is intended
* otherwise we end up with -0001-11-30 ...
* add 32 days so that we at least get year 00, and then hack around the fact that
* months and days always start with 1.
*/
if (substr($s, 0, 10) <= '0001-01-01') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
return str_replace('1', '0', $d->format($format));
}
try {
$from_obj = new DateTimeZone($tz_from);
} catch (Exception $e) {
$from_obj = new DateTimeZone('UTC');
}
try {
$d = new DateTime($s, $from_obj);
} catch (Exception $e) {
logger('datetime_convert: exception: ' . $e->getMessage());
$d = new DateTime('now', $from_obj);
}
try {
$to_obj = new DateTimeZone($tz_to);
} catch (Exception $e) {
$to_obj = new DateTimeZone('UTC');
}
$d->setTimeZone($to_obj);
return $d->format($format);
}
}

View file

@ -73,7 +73,7 @@ class ParseUrl
[ [
'url' => normalise_link($url), 'guessing' => !$no_guessing, 'url' => normalise_link($url), 'guessing' => !$no_guessing,
'oembed' => $do_oembed, 'content' => serialize($data), 'oembed' => $do_oembed, 'content' => serialize($data),
'created' => Temporal::utcNow() 'created' => DateTimeFormat::utcNow()
], ],
true true
); );

View file

@ -8,7 +8,6 @@ namespace Friendica\Util;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
use Exception;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
@ -21,9 +20,6 @@ require_once 'include/text.php';
*/ */
class Temporal class Temporal
{ {
const ATOM = 'Y-m-d\TH:i:s\Z';
const MYSQL = 'Y-m-d H:i:s';
/** /**
* @brief Two-level sort for timezones. * @brief Two-level sort for timezones.
* *
@ -123,125 +119,6 @@ class Temporal
]); ]);
} }
/**
* 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 local.
*
* @param string $time A date/time string
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function local($time, $format = self::MYSQL)
{
return self::convert($time, date_default_timezone_get(), 'UTC', $format);
}
/**
* convert() shorthand for timezoned now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function timezoneNow($timezone, $format = self::MYSQL)
{
return self::convert('now', $timezone, 'UTC', $format);
}
/**
* convert() shorthand for local now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function localNow($format = self::MYSQL)
{
return self::local('now', $format);
}
/**
* convert() shorthand for UTC now.
*
* @param string $format DateTime format string or Temporal constant
* @return string
*/
public static function utcNow($format = self::MYSQL)
{
return self::utc('now', $format);
}
/**
* @brief General purpose date parse/convert/format function.
*
* @param string $s Some parseable date/time string
* @param string $tz_to Destination timezone
* @param string $tz_from Source timezone
* @param string $format Output format recognised from php's DateTime class
* http://www.php.net/manual/en/datetime.format.php
*
* @return string Formatted date according to given format
*/
public static function convert($s = 'now', $tz_to = 'UTC', $tz_from = 'UTC', $format = self::MYSQL)
{
// Defaults to UTC if nothing is set, but throws an exception if set to empty string.
// Provide some sane defaults regardless.
if ($from === '') {
$from = 'UTC';
}
if ($to === '') {
$to = 'UTC';
}
if (($s === '') || (!is_string($s))) {
$s = 'now';
}
/*
* Slight hackish adjustment so that 'zero' datetime actually returns what is intended
* otherwise we end up with -0001-11-30 ...
* add 32 days so that we at least get year 00, and then hack around the fact that
* months and days always start with 1.
*/
if (substr($s, 0, 10) <= '0001-01-01') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
return str_replace('1', '0', $d->format($format));
}
try {
$from_obj = new DateTimeZone($tz_from);
} catch (Exception $e) {
$from_obj = new DateTimeZone('UTC');
}
try {
$d = new DateTime($s, $from_obj);
} catch (Exception $e) {
logger('datetime_convert: exception: ' . $e->getMessage());
$d = new DateTime('now', $from_obj);
}
try {
$to_obj = new DateTimeZone($tz_to);
} catch (Exception $e) {
$to_obj = new DateTimeZone('UTC');
}
$d->setTimeZone($to_obj);
return $d->format($format);
}
/** /**
* @brief Wrapper for date selector, tailored for use in birthday fields. * @brief Wrapper for date selector, tailored for use in birthday fields.
* *

View file

@ -8,7 +8,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -71,7 +71,7 @@ Class Cron {
// once daily run birthday_updates and then expire in background // once daily run birthday_updates and then expire in background
$d1 = Config::get('system', 'last_expire_day'); $d1 = Config::get('system', 'last_expire_day');
$d2 = intval(Temporal::utcNow('d')); $d2 = intval(DateTimeFormat::utcNow('d'));
if ($d2 != intval($d1)) { if ($d2 != intval($d1)) {
@ -142,7 +142,7 @@ Class Cron {
Addon::reload(); Addon::reload();
$d = Temporal::utcNow(); $d = DateTimeFormat::utcNow();
// Only poll from those with suitable relationships, // Only poll from those with suitable relationships,
// and which have a polling address and ignore Diaspora since // and which have a polling address and ignore Diaspora since
@ -218,33 +218,33 @@ Class Cron {
*/ */
switch ($contact['priority']) { switch ($contact['priority']) {
case 5: case 5:
if (Temporal::utcNow() > Temporal::utc($t . " + 1 month")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 month")) {
$update = true; $update = true;
} }
break; break;
case 4: case 4:
if (Temporal::utcNow() > Temporal::utc($t . " + 1 week")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 week")) {
$update = true; $update = true;
} }
break; break;
case 3: case 3:
if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 day")) {
$update = true; $update = true;
} }
break; break;
case 2: case 2:
if (Temporal::utcNow() > Temporal::utc($t . " + 12 hour")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 12 hour")) {
$update = true; $update = true;
} }
break; break;
case 1: case 1:
if (Temporal::utcNow() > Temporal::utc($t . " + 1 hour")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 hour")) {
$update = true; $update = true;
} }
break; break;
case 0: case 0:
default: default:
if (Temporal::utcNow() > Temporal::utc($t . " + ".$min_poll_interval." minute")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + ".$min_poll_interval." minute")) {
$update = true; $update = true;
} }
break; break;

View file

@ -8,7 +8,7 @@ namespace Friendica\Worker;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
Class CronHooks { Class CronHooks {
public static function execute($hook = '') { public static function execute($hook = '') {
@ -45,7 +45,7 @@ Class CronHooks {
logger('cronhooks: start'); logger('cronhooks: start');
$d = Temporal::utcNow(); $d = DateTimeFormat::utcNow();
if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) { if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $hook) { foreach ($a->hooks["cron"] as $hook) {

View file

@ -11,8 +11,8 @@ use Friendica\Database\DBM;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
require_once 'include/datetime.php'; require_once 'include/datetime.php';
@ -198,7 +198,7 @@ class DiscoverPoCo {
} }
} else { } else {
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'", q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
dbesc(Temporal::utcNow()), dbesc(normalise_link($user["url"]))); dbesc(DateTimeFormat::utcNow()), dbesc(normalise_link($user["url"])));
} }
// Quit the loop after 3 minutes // Quit the loop after 3 minutes

View file

@ -15,6 +15,7 @@ use Friendica\Protocol\PortableContact;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -44,7 +45,7 @@ class OnePoll
return; return;
} }
$d = Temporal::utcNow(); $d = DateTimeFormat::utcNow();
$contact = dba::selectFirst('contact', [], ['id' => $contact_id]); $contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
if (!DBM::is_result($contact)) { if (!DBM::is_result($contact)) {
@ -70,7 +71,7 @@ class OnePoll
// Diaspora users, archived users and followers are only checked if they still exist. // Diaspora users, archived users and followers are only checked if they still exist.
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) { if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
$last_updated = PortableContact::lastUpdated($contact["url"], true); $last_updated = PortableContact::lastUpdated($contact["url"], true);
$updated = Temporal::utcNow(); $updated = DateTimeFormat::utcNow();
if ($last_updated) { if ($last_updated) {
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG); logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
@ -99,7 +100,7 @@ class OnePoll
$contact['priority'] = intval($poll_interval); $contact['priority'] = intval($poll_interval);
$hub_update = false; $hub_update = false;
if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) { if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 day")) {
$hub_update = true; $hub_update = true;
} }
} else { } else {
@ -107,8 +108,8 @@ class OnePoll
} }
$last_update = (($contact['last-update'] <= NULL_DATE) $last_update = (($contact['last-update'] <= NULL_DATE)
? Temporal::utc('now - 7 days', Temporal::ATOM) ? DateTimeFormat::utc('now - 7 days', DateTimeFormat::ATOM)
: Temporal::utc($contact['last-update'], Temporal::ATOM) : DateTimeFormat::utc($contact['last-update'], DateTimeFormat::ATOM)
); );
// Update the contact entry // Update the contact entry
@ -117,7 +118,7 @@ class OnePoll
logger("Skipping probably dead contact ".$contact['url']); logger("Skipping probably dead contact ".$contact['url']);
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} }
@ -126,7 +127,7 @@ class OnePoll
logger('Contact is marked dead'); logger('Contact is marked dead');
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} else { } else {
Contact::unmarkForArchival($contact); Contact::unmarkForArchival($contact);
@ -137,7 +138,7 @@ class OnePoll
logger('Ignore public contacts'); logger('Ignore public contacts');
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} }
@ -149,7 +150,7 @@ class OnePoll
logger('No self contact for user '.$importer_uid); logger('No self contact for user '.$importer_uid);
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} }
@ -185,7 +186,7 @@ class OnePoll
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact); Contact::markForArchival($contact);
return; return;
} }
@ -207,7 +208,7 @@ class OnePoll
Contact::markForArchival($contact); Contact::markForArchival($contact);
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; $fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
self::updateContact($contact, $fields); self::updateContact($contact, $fields);
return; return;
} }
@ -217,7 +218,7 @@ class OnePoll
Contact::markForArchival($contact); Contact::markForArchival($contact);
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; $fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
self::updateContact($contact, $fields); self::updateContact($contact, $fields);
return; return;
} }
@ -230,7 +231,7 @@ class OnePoll
// we may not be friends anymore. Will keep trying for one month. // we may not be friends anymore. Will keep trying for one month.
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; $fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
self::updateContact($contact, $fields); self::updateContact($contact, $fields);
Contact::markForArchival($contact); Contact::markForArchival($contact);
@ -241,7 +242,7 @@ class OnePoll
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) { if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} }
@ -276,7 +277,7 @@ class OnePoll
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id); logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact); Contact::markForArchival($contact);
return; return;
} }
@ -311,7 +312,7 @@ class OnePoll
if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) { if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return; return;
} }
@ -321,7 +322,7 @@ class OnePoll
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) { if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact); Contact::markForArchival($contact);
return; return;
} }
@ -335,7 +336,7 @@ class OnePoll
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
if ($mail_disabled) { if ($mail_disabled) {
// set the last-update so we don't keep polling // set the last-update so we don't keep polling
dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]); dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact); Contact::markForArchival($contact);
return; return;
} }
@ -355,7 +356,7 @@ class OnePoll
unset($password); unset($password);
logger("Mail: Connect to " . $mailconf['user']); logger("Mail: Connect to " . $mailconf['user']);
if ($mbox) { if ($mbox) {
$fields = ['last_check' => Temporal::utcNow()]; $fields = ['last_check' => DateTimeFormat::utcNow()];
dba::update('mailacct', $fields, ['id' => $mailconf['id']]); dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
logger("Mail: Connected to " . $mailconf['user']); logger("Mail: Connected to " . $mailconf['user']);
} else { } else {
@ -395,7 +396,7 @@ class OnePoll
// Only delete when mails aren't automatically moved or deleted // Only delete when mails aren't automatically moved or deleted
if (($mailconf['action'] != 1) && ($mailconf['action'] != 3)) if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
if ($meta->deleted && ! $item['deleted']) { if ($meta->deleted && ! $item['deleted']) {
$fields = ['deleted' => true, 'changed' => Temporal::utcNow()]; $fields = ['deleted' => true, 'changed' => DateTimeFormat::utcNow()];
dba::update('item', $fields, ['id' => $item['id']]); dba::update('item', $fields, ['id' => $item['id']]);
} }
@ -459,7 +460,7 @@ class OnePoll
$datarray['title'] = notags(trim($datarray['title'])); $datarray['title'] = notags(trim($datarray['title']));
//$datarray['title'] = notags(trim($meta->subject)); //$datarray['title'] = notags(trim($meta->subject));
$datarray['created'] = Temporal::utc($meta->date); $datarray['created'] = DateTimeFormat::utc($meta->date);
// Is it a reply? // Is it a reply?
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") || $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
@ -572,7 +573,7 @@ class OnePoll
if (!strstr($xml, '<')) { if (!strstr($xml, '<')) {
logger('post_handshake: response from ' . $url . ' did not contain XML.'); logger('post_handshake: response from ' . $url . ' did not contain XML.');
$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()]; $fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
self::updateContact($contact, $fields); self::updateContact($contact, $fields);
Contact::markForArchival($contact); Contact::markForArchival($contact);
return; return;
@ -616,19 +617,19 @@ class OnePoll
} }
} }
$updated = Temporal::utcNow(); $updated = DateTimeFormat::utcNow();
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]); self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]); dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
Contact::unmarkForArchival($contact); Contact::unmarkForArchival($contact);
} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) { } elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
$updated = Temporal::utcNow(); $updated = DateTimeFormat::utcNow();
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]); self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]); dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
Contact::markForArchival($contact); Contact::markForArchival($contact);
} else { } else {
$updated = Temporal::utcNow(); $updated = DateTimeFormat::utcNow();
dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]); dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
} }

View file

@ -9,7 +9,7 @@ namespace Friendica\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\Temporal; use Friendica\Util\DateTimeFormat;
class UpdateGContact class UpdateGContact
{ {
@ -42,7 +42,7 @@ class UpdateGContact
} }
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d", q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
dbesc(Temporal::utcNow()), intval($contact_id)); dbesc(DateTimeFormat::utcNow()), intval($contact_id));
return; return;
} }