Browse Source

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

pull/4327/head
Hypolite Petovan 4 years ago
parent
commit
5e7285b9ba
  1. 8
      boot.php
  2. 20
      include/api.php
  3. 10
      include/bb2diaspora.php
  4. 4
      include/conversation.php
  5. 6
      include/dba.php
  6. 4
      include/enotify.php
  7. 66
      include/event.php
  8. 24
      include/items.php
  9. 6
      include/security.php
  10. 6
      include/text.php
  11. 4
      mod/admin.php
  12. 16
      mod/cal.php
  13. 6
      mod/contacts.php
  14. 14
      mod/dfrn_confirm.php
  15. 10
      mod/dfrn_request.php
  16. 44
      mod/events.php
  17. 4
      mod/fsuggest.php
  18. 4
      mod/invite.php
  19. 16
      mod/item.php
  20. 2
      mod/localtime.php
  21. 6
      mod/lostpass.php
  22. 6
      mod/message.php
  23. 12
      mod/network.php
  24. 18
      mod/photos.php
  25. 12
      mod/ping.php
  26. 7
      mod/poco.php
  27. 8
      mod/profile.php
  28. 6
      mod/profile_photo.php
  29. 12
      mod/profiles.php
  30. 4
      mod/proxy.php
  31. 4
      mod/pubsubhubbub.php
  32. 4
      mod/register.php
  33. 3
      mod/settings.php
  34. 6
      mod/videos.php
  35. 4
      mod/wall_attach.php
  36. 4
      src/Content/OEmbed.php
  37. 20
      src/Core/Cache.php
  38. 10
      src/Core/NotificationsManager.php
  39. 19
      src/Core/Worker.php
  40. 4
      src/Database/DBM.php
  41. 44
      src/Model/Contact.php
  42. 12
      src/Model/GContact.php
  43. 3
      src/Model/Item.php
  44. 10
      src/Model/Mail.php
  45. 6
      src/Model/Photo.php
  46. 4
      src/Model/Process.php
  47. 28
      src/Model/Profile.php
  48. 13
      src/Model/Queue.php
  49. 6
      src/Model/User.php
  50. 10
      src/Module/Login.php
  51. 4
      src/Network/FKOAuth1.php
  52. 8
      src/Object/Post.php
  53. 52
      src/Protocol/DFRN.php
  54. 71
      src/Protocol/Diaspora.php
  55. 18
      src/Protocol/OStatus.php
  56. 42
      src/Protocol/PortableContact.php
  57. 139
      src/Util/DateTimeFormat.php
  58. 2
      src/Util/ParseUrl.php
  59. 123
      src/Util/Temporal.php
  60. 18
      src/Worker/Cron.php
  61. 4
      src/Worker/CronHooks.php
  62. 4
      src/Worker/DiscoverPoCo.php
  63. 51
      src/Worker/OnePoll.php
  64. 4
      src/Worker/UpdateGContact.php

8
boot.php

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

20
include/api.php

@ -36,8 +36,8 @@ use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
require_once 'include/bbcode.php';
@ -111,7 +111,7 @@ function api_source()
function api_date($str)
{
// 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,
'base' => System::baseUrl(),
'updated' => api_date(null),
'atom_updated' => Temporal::utcNow(Temporal::ATOM),
'atom_updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'language' => $user_info['language'],
'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)
$throttle_day = Config::get('system', 'throttle_limit_day');
if ($throttle_day > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$r = q(
"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');
if ($throttle_week > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60*7);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$r = q(
"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');
if ($throttle_month > 0) {
$datefrom = date(Temporal::MYSQL, time() - 24*60*60*30);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$r = q(
"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"],
'hourly-limit' => '150',
'@attributes2' => ["type" => "integer"],
'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM),
'reset-time' => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM),
'@attributes3' => ["type" => "datetime"],
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'@attributes4' => ["type" => "integer"],
@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type)
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'remaining_hits' => '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(
"UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'",
$sql_extra,
Temporal::utcNow(), // update edited timestamp
DateTimeFormat::utcNow(), // update edited timestamp
intval(api_user()),
dbesc($photo_id),
dbesc($album)
@ -4420,7 +4420,7 @@ function api_account_update_profile_image($type)
q(
"UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
intval(local_user())
);

10
include/bb2diaspora.php

@ -7,7 +7,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use League\HTMLToMarkdown\HtmlConverter;
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
$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']) {
$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'])) {

4
include/conversation.php

@ -17,7 +17,7 @@ use Friendica\Model\Profile;
use Friendica\Object\Post;
use Friendica\Util\XML;
use Friendica\Object\Thread;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
@ -790,7 +790,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'categories' => $categories,
'folders' => $folders,
'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'])),
'location' => $location_e,
'indent' => '',

6
include/dba.php

@ -4,7 +4,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once('include/datetime.php');
@ -190,7 +190,7 @@ class dba {
if ($log) {
$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".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
@ -495,7 +495,7 @@ class dba {
$duration = round($duration, 3);
$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".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND);

4
include/enotify.php

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

66
include/event.php

@ -12,8 +12,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php';
require_once 'include/datetime.php';
@ -28,14 +28,14 @@ function format_event_html($ev, $simple = false) {
$event_start = day_translate(
$ev['adjust'] ?
Temporal::local($ev['start'], $bd_format)
: Temporal::utc($ev['start'], $bd_format)
DateTimeFormat::local($ev['start'], $bd_format)
: DateTimeFormat::utc($ev['start'], $bd_format)
);
$event_end = day_translate(
$ev['adjust'] ?
Temporal::local($ev['finish'], $bd_format)
: Temporal::utc($ev['finish'], $bd_format)
DateTimeFormat::local($ev['finish'], $bd_format)
: DateTimeFormat::utc($ev['finish'], $bd_format)
);
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="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
. '</span></div>' . "\r\n";
if (! $ev['nofinish']) {
$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
. '</span></div>' . "\r\n";
}
@ -200,8 +200,8 @@ function sort_by_date($a) {
function ev_compare($a,$b) {
$date_a = (($a['adjust']) ? Temporal::local($a['start']) : $a['start']);
$date_b = (($b['adjust']) ? Temporal::local($b['start']) : $b['start']);
$date_a = (($a['adjust']) ? DateTimeFormat::local($a['start']) : $a['start']);
$date_b = (($b['adjust']) ? DateTimeFormat::local($b['start']) : $b['start']);
if ($date_a === $date_b) {
return strcasecmp($a['desc'], $b['desc']);
@ -244,8 +244,8 @@ function event_store($arr) {
$a = get_app();
$arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::utcNow());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::utcNow());
$arr['created'] = (($arr['created']) ? $arr['created'] : DateTimeFormat::utcNow());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : DateTimeFormat::utcNow());
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
$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');
if (count($arr)) {
foreach ($arr as $rr) {
$j = (($rr['adjust']) ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'));
$d = (($rr['adjust']) ? Temporal::local($rr['start'], $fmt) : Temporal::utc($rr['start'], $fmt));
$j = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'));
$d = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], $fmt) : DateTimeFormat::utc($rr['start'], $fmt));
$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']) {
$end = null;
} 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);
@ -930,27 +930,27 @@ function format_event_item($item) {
// Convert the time to different formats.
$dtstart_dt = day_translate(
$item['event-adjust'] ?
Temporal::local($item['event-start'], $dformat)
: Temporal::utc($item['event-start'], $dformat)
DateTimeFormat::local($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.
$month_short = day_short_translate(
$item['event-adjust'] ?
Temporal::local($item['event-start'], 'M')
: Temporal::utc($item['event-start'], 'M')
DateTimeFormat::local($item['event-start'], 'M')
: DateTimeFormat::utc($item['event-start'], 'M')
);
// Format: 1 till 31.
$date_short = $item['event-adjust'] ?
Temporal::local($item['event-start'], 'j')
: Temporal::utc($item['event-start'], 'j');
DateTimeFormat::local($item['event-start'], 'j')
: DateTimeFormat::utc($item['event-start'], 'j');
$start_time = $item['event-adjust'] ?
Temporal::local($item['event-start'], $tformat)
: Temporal::utc($item['event-start'], $tformat);
DateTimeFormat::local($item['event-start'], $tformat)
: DateTimeFormat::utc($item['event-start'], $tformat);
$start_short = day_short_translate(
$item['event-adjust'] ?
Temporal::local($item['event-start'], $dformat_short)
: Temporal::utc($item['event-start'], $dformat_short)
DateTimeFormat::local($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.
@ -958,18 +958,18 @@ function format_event_item($item) {
$finish = true;
$dtend_dt = day_translate(
$item['event-adjust'] ?
Temporal::local($item['event-finish'], $dformat)
: Temporal::utc($item['event-finish'], $dformat)
DateTimeFormat::local($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(
$item['event-adjust'] ?
Temporal::local($item['event-finish'], $dformat_short)
: Temporal::utc($item['event-finish'], $dformat_short)
DateTimeFormat::local($item['event-finish'], $dformat_short)
: DateTimeFormat::utc($item['event-finish'], $dformat_short)
);
$end_time = $item['event-adjust'] ?
Temporal::local($item['event-finish'], $tformat)
: Temporal::utc($item['event-finish'], $tformat);
DateTimeFormat::local($item['event-finish'], $tformat)
: DateTimeFormat::utc($item['event-finish'], $tformat);
// Check if start and finish time is at the same day.
if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) {
$same_date = true;

24
include/items.php

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

6
include/security.php

@ -10,7 +10,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
/**
* @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'] . '"');
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
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]);
}

6
include/text.php

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

4
mod/admin.php

@ -20,7 +20,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once 'include/enotify.php';
require_once 'include/text.php';
@ -740,7 +740,7 @@ function admin_page_summary(App $a)
if (!$last_worker_call) {
$showwarning = true;
$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;
$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);
}

16
mod/cal.php

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

6
mod/contacts.php

@ -17,7 +17,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
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.');
$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) {
$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
$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;
if ($contact['network'] == NETWORK_FEED) {

14
mod/dfrn_confirm.php

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

10
mod/dfrn_request.php

@ -24,8 +24,8 @@ use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
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`)
VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)",
intval(local_user()),
Temporal::utcNow(),
DateTimeFormat::utcNow(),
dbesc($dfrn_url),
dbesc(normalise_link($dfrn_url)),
$parms['addr'],
@ -241,7 +241,7 @@ function dfrn_request_post(App $a)
// Block friend request spam
if ($maxreq) {
$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)
);
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` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )",
intval($uid),
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
$parms['url'],
dbesc(normalise_link($url)),
$parms['addr'],
@ -430,7 +430,7 @@ function dfrn_request_post(App $a)
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
dbesc(notags(trim($_POST['dfrn-request-message']))),
dbesc($hash),
dbesc(Temporal::utcNow())
dbesc(DateTimeFormat::utcNow())
);
}

44
mod/events.php

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

4
mod/fsuggest.php

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

4
mod/invite.php

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

16
mod/item.php

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

2
mod/localtime.php

@ -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
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);
}
}

6
mod/lostpass.php

@ -8,7 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once 'boot.php';
require_once 'include/datetime.php';
@ -33,7 +33,7 @@ function lostpass_post(App $a)
$fields = [
'pwdreset' => $pwdreset_token,
'pwdreset_time' => Temporal::utcNow()
'pwdreset_time' => DateTimeFormat::utcNow()
];
$result = dba::update('user', $fields, ['uid' => $user['uid']]);
if ($result) {
@ -92,7 +92,7 @@ function lostpass_content(App $a)
}
// 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 = [
'pwdreset' => null,
'pwdreset_time' => null

6
mod/message.php

@ -11,7 +11,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once 'include/acl_selectors.php';
require_once 'include/conversation.php';
@ -397,7 +397,7 @@ function message_content(App $a)
'body' => $body_e,
'delete' => L10n::t('Delete message'),
'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']),
];
@ -498,7 +498,7 @@ function render_messages(array $msg, $t)
'$delete' => L10n::t('Delete conversation'),
'$body' => $body_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']),
'$seen' => $rr['mailseen'],
'$count' => L10n::tt('%d message', '%d messages', $rr['count']),

12
mod/network.php

@ -19,7 +19,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
require_once 'include/conversation.php';
require_once 'include/items.php';
@ -681,11 +681,11 @@ function networkThreadedView(App $a, $update = 0)
if ($datequery) {
$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) {
$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 = '';
@ -790,8 +790,8 @@ function networkThreadedView(App $a, $update = 0)
$top_limit = current($r)['order_date'];
$bottom_limit = end($r)['order_date'];
} else {
$top_limit = Temporal::utcNow();
$bottom_limit = Temporal::utcNow();
$top_limit = DateTimeFormat::utcNow();
$bottom_limit = DateTimeFormat::utcNow();
}
// 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;
} elseif ($a->pager['page'] == 1) {
// 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`

18
mod/photos.php

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

12
mod/ping.php

@ -14,7 +14,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML;
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
ORDER BY `start` ASC ",
intval(local_user()),
dbesc(Temporal::utc('now + 7 days')),
dbesc(Temporal::utcNow())
dbesc(DateTimeFormat::utc('now + 7 days')),
dbesc(DateTimeFormat::utcNow())
);
if (DBM::is_result($ev)) {
Cache::set($cachekey, $ev, CACHE_HOUR);
@ -237,7 +237,7 @@ function ping_init(App $a)
$all_events = count($ev);
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) {
$bd = false;
if ($x['type'] === 'birthday') {
@ -246,7 +246,7 @@ function ping_init(App $a)
} else {
$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 ++;
if ($bd) {
$birthdays_today ++;
@ -362,7 +362,7 @@ function ping_init(App $a)
$notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO);
}
$local_time = Temporal::local($notif['date']);
$local_time = DateTimeFormat::local($notif['date']);
$notifications[] = [
'id' => $notif['id'],

7
mod/poco.php

@ -3,13 +3,14 @@
// See here for a documentation for portable contacts:
// https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html
use Friendica\App;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Protocol\PortableContact;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
function poco_init(App $a) {
$system_mode = false;
@ -44,7 +45,7 @@ function poco_init(App $a) {
if ($a->argc > 1 && $a->argv[1] === '@global') {
// List of all profiles that this server recently had data from
$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') {
$justme = true;
@ -81,7 +82,7 @@ function poco_init(App $a) {
$sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid));
}
if (x($_GET, 'updatedSince')) {
$update_limit = date(Temporal::MYSQL, strtotime($_GET['updatedSince']));
$update_limit = date(DateTimeFormat::MYSQL, strtotime($_GET['updatedSince']));
}
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')",

8
mod/profile.php

@ -16,7 +16,7 @@ use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
function profile_init(App $a)
{
@ -236,7 +236,7 @@ function profile_content(App $a, $update = 0)
if ($is_owner || !$last_updated) {
$sql_extra4 = " AND `item`.`unseen`";
} else {
$gmupdate = gmdate(Temporal::MYSQL, $last_updated);
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
$sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'";
}
@ -272,10 +272,10 @@ function profile_content(App $a, $update = 0)
}
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) {
$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?

6
mod/profile_photo.php

@ -12,7 +12,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Object\Image;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
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
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
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",
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
intval(local_user())
);

12
mod/profiles.php

@ -18,7 +18,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
function profiles_init(App $a) {
@ -220,9 +220,9 @@ function profiles_post(App $a) {
}
if ($ignore_year) {
$dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d');
$dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
} 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)) {
$howlong = NULL_DATE;
} 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
@ -488,7 +488,7 @@ function profiles_post(App $a) {
if ($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc($name),
dbesc(Temporal::utcNow()),
dbesc(DateTimeFormat::utcNow()),
intval(local_user())
);
$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']),
'$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')],
'$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']),
'$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.")],

4
mod/proxy.php

@ -10,8 +10,8 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -188,7 +188,7 @@ function proxy_init(App $a) {
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),
'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0,
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime];

4
mod/pubsubhubbub.php

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

4
mod/register.php

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

3
mod/settings.php

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

6
mod/videos.php

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

4
mod/wall_attach.php

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