Browse Source

Refactor datetime_convert into Temporal::convert

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

15
boot.php

@ -21,16 +21,15 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'a
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendida\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Database\DBStructure;
use Friendica\Module\Login;
use Friendica\Model\Contact;
use Friendica\Util\Temporal;
use Friendida\Core\L10n;
require_once 'include/text.php';
require_once 'include/datetime.php';
@ -1144,14 +1143,14 @@ function feed_birthday($uid, $tz)
if (DBM::is_result($p)) {
$tmp_dob = substr($p[0]['dob'], 5);
if (intval($tmp_dob)) {
$y = datetime_convert($tz, $tz, 'now', 'Y');
$y = Temporal::convert('now', $tz, $tz, 'Y');
$bd = $y . '-' . $tmp_dob . ' 00:00';
$t_dob = strtotime($bd);
$now = strtotime(datetime_convert($tz, $tz, 'now'));
$now = strtotime(Temporal::convert('now', $tz, $tz));
if ($t_dob < $now) {
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
}
$birthday = datetime_convert($tz, 'UTC', $bd, ATOM_TIME);
$birthday = Temporal::convert($bd, 'UTC', $tz, ATOM_TIME);
}
}

22
include/api.php

@ -5,24 +5,25 @@
* @file include/api.php
* @todo Automatically detect if incoming data is HTML or BBCode
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\NotificationsManager;
use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Mail;
use Friendica\Model\Photo;
use Friendica\Model\User;
use Friendica\Model\Item;
use Friendica\Network\FKOAuth1;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\BadRequestException;
@ -31,11 +32,12 @@ use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\MethodNotAllowedException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\NotImplementedException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Network\HTTPException\TooManyRequestsException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
require_once 'include/bbcode.php';
@ -109,7 +111,7 @@ function api_source()
function api_date($str)
{
// Wed May 23 06:01:13 +0000 2007
return datetime_convert('UTC', 'UTC', $str, "D M d H:i:s +0000 Y");
return Temporal::convert($str, 'UTC', 'UTC', "D M d H:i:s +0000 Y");
}
/**
@ -458,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' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME),
'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', ATOM_TIME),
'language' => $user_info['language'],
'logo' => System::baseUrl() . "/images/friendica-32.png",
];
@ -3205,7 +3207,7 @@ function api_account_rate_limit_status($type)
'@attributes' => ["type" => "integer"],
'hourly-limit' => '150',
'@attributes2' => ["type" => "integer"],
'reset-time' => datetime_convert('UTC', 'UTC', 'now + 1 hour', ATOM_TIME),
'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME),
'@attributes3' => ["type" => "datetime"],
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'@attributes4' => ["type" => "integer"],
@ -3215,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(datetime_convert('UTC', 'UTC', 'now + 1 hour', ATOM_TIME)),
'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME)),
];
}
@ -4214,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,
datetime_convert(), // update edited timestamp
Temporal::convert(), // update edited timestamp
intval(api_user()),
dbesc($photo_id),
dbesc($album)
@ -4418,7 +4420,7 @@ function api_account_update_profile_image($type)
q(
"UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(datetime_convert()),
dbesc(Temporal::convert()),
intval(local_user())
);

21
include/bb2diaspora.php

@ -3,9 +3,11 @@
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
use League\HTMLToMarkdown\HtmlConverter;
require_once 'include/event.php';
@ -241,20 +243,19 @@ function format_event_diaspora($ev) {
$o .= '**' . (($ev['summary']) ? bb2diaspora($ev['summary']) : bb2diaspora($ev['desc'])) . '**' . "\n";
// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
$o .= L10n::t('Starts:') . ' ' . '['
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['start'])) . ")\n";
. (($ev['adjust']) ? day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
: day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
)
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['start'])) . ")\n";
if (! $ev['nofinish']) {
$o .= L10n::t('Finishes:') . ' ' . '['
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(datetime_convert('UTC','UTC',$ev['finish'])) . ")\n";
. (($ev['adjust']) ? day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
: day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
)
. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['finish'])) . ")\n";
}
if (strlen($ev['location'])) {

6
include/conversation.php

@ -2,6 +2,7 @@
/**
* @file include/conversation.php
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
@ -13,9 +14,10 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
use Friendica\Object\Thread;
use Friendica\Object\Post;
use Friendica\Util\XML;
use Friendica\Object\Thread;
use Friendica\Util\Temporal;
require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
@ -788,7 +790,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'categories' => $categories,
'folders' => $folders,
'text' => strip_tags($body_e),
'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'),
'localtime' => Temporal::convert($item['created'], date_default_timezone_get(), 'UTC', 'r'),
'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'location' => $location_e,
'indent' => '',

12
include/datetime.php

@ -7,18 +7,6 @@
use Friendica\Model\Contact;
use Friendica\Util\Temporal;
function select_timezone($current = 'America/Los_Angeles') {
return Temporal::getTimezoneSelect($current);
}
function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help = ''){
return Temporal::getTimezoneField($name, $label, $current, $help);
}
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
return Temporal::convert($s, $to, $from, $fmt);
}
function dob($dob) {
return Temporal::getDateofBirthField($dob);
}

7
include/dba.php

@ -1,7 +1,10 @@
<?php
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Util\Temporal;
require_once('include/datetime.php');
@ -187,7 +190,7 @@ class dba {
if ($log) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log_index"], datetime_convert()."\t".
@file_put_contents($a->config["system"]["db_log_index"], Temporal::convert()."\t".
$row['key']."\t".$row['rows']."\t".$row['Extra']."\t".
basename($backtrace[1]["file"])."\t".
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
@ -492,7 +495,7 @@ class dba {
$duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log"], datetime_convert()."\t".$duration."\t".
@file_put_contents($a->config["system"]["db_log"], Temporal::convert()."\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);

5
include/enotify.php

@ -2,13 +2,14 @@
/**
* @file include/enotify.php
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Util\Emailer;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php';
require_once 'include/html2bbcode.php';
@ -450,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'] = datetime_convert();
$datarray['date'] = Temporal::convert();
$datarray['uid'] = $params['uid'];
$datarray['link'] = $itemlink;
$datarray['iid'] = $item_id;

56
include/event.php

@ -4,7 +4,6 @@
* @brief functions specific to event handling
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
@ -14,6 +13,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php';
require_once 'include/datetime.php';
@ -26,15 +26,13 @@ function format_event_html($ev, $simple = false) {
$bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM.
$event_start = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)));
$event_start = (($ev['adjust']) ?
day_translate(Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format))
: day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format)));
$event_end = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )));
$event_end = (($ev['adjust']) ?
day_translate(Temporal::convert($ev['finish'] , date_default_timezone_get(), 'UTC', $bd_format ))
: day_translate(Temporal::convert($ev['finish'] , 'UTC', 'UTC', $bd_format )));
if ($simple) {
$o = "<h3>" . bbcode($ev['summary']) . "</h3>";
@ -59,13 +57,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="'
. datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. Temporal::convert($ev['start'], 'UTC', 'UTC', (($ev['adjust']) ? ATOM_TIME : '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="'
. datetime_convert('UTC', 'UTC', $ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. Temporal::convert($ev['finish'], 'UTC', 'UTC', (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'.$event_end
. '</span></div>' . "\r\n";
}
@ -198,8 +196,8 @@ function sort_by_date($a) {
function ev_compare($a,$b) {
$date_a = (($a['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $a['start']) : $a['start']);
$date_b = (($b['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $b['start']) : $b['start']);
$date_a = (($a['adjust']) ? Temporal::convert($a['start'], date_default_timezone_get()) : $a['start']);
$date_b = (($b['adjust']) ? Temporal::convert($b['start'], date_default_timezone_get()) : $b['start']);
if ($date_a === $date_b) {
return strcasecmp($a['desc'], $b['desc']);
@ -242,8 +240,8 @@ function event_store($arr) {
$a = get_app();
$arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
$arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::convert());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::convert());
$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']));
@ -593,15 +591,15 @@ function process_events($arr) {
$fmt = L10n::t('l, F j');
if (count($arr)) {
foreach ($arr as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
$d = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt));
$j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
$d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::convert($rr['start'], 'UTC', 'UTC', $fmt));
$d = day_translate($d);
$start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c'));
$start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'c'));
if ($rr['nofinish']) {
$end = null;
} else {
$end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c'));
$end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['finish'], 'UTC', 'UTC', 'c'));
}
$is_first = ($d !== $last_date);
@ -926,22 +924,22 @@ function format_event_item($item) {
$tformat = L10n::t('g:i A'); // 8:01 AM.
// Convert the time to different formats.
$dtstart_dt = (($item['event-adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $item['event-start'], $dformat)) : day_translate(datetime_convert('UTC', 'UTC', $item['event-start'], $dformat)));
$dtstart_title = datetime_convert('UTC', 'UTC', $item['event-start'], (($item['event-adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s'));
$dtstart_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat)));
$dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s'));
// Format: Jan till Dec.
$month_short = (($item['event-adjust']) ? day_short_translate(datetime_convert('UTC', date_default_timezone_get(), $item['event-start'], 'M')) : day_short_translate(datetime_convert('UTC', 'UTC', $item['event-start'], 'M')));
$month_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M')) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', 'M')));
// Format: 1 till 31.
$date_short = (($item['event-adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $item['event-start'], 'j') : datetime_convert('UTC', 'UTC', $item['event-start'], 'j'));
$start_time = (($item['event-adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $item['event-start'], $tformat) : datetime_convert('UTC', 'UTC', $item['event-start'], $tformat));
$start_short = (($item['event-adjust']) ? day_short_translate(datetime_convert('UTC', date_default_timezone_get(), $item['event-start'], $dformat_short)) : day_short_translate(datetime_convert('UTC', 'UTC', $item['event-start'], $dformat_short)));
$date_short = (($item['event-adjust']) ? Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($item['event-start'], 'UTC', 'UTC', 'j'));
$start_time = (($item['event-adjust']) ? Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-start'], 'UTC', 'UTC', $tformat));
$start_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-start'], 'UTC', 'UTC', $dformat_short)));
// If the option 'nofinisch' isn't set, we need to format the finish date/time.
if (!$item['event-nofinish']) {
$finish = true;
$dtend_dt = (($item['event-adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $item['event-finish'], $dformat)) : day_translate(datetime_convert('UTC', 'UTC', $item['event-finish'], $dformat)));
$dtend_title = datetime_convert('UTC', 'UTC', $item['event-finish'], (($item['event-adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s'));
$end_short = (($item['event-adjust']) ? day_short_translate(datetime_convert('UTC', date_default_timezone_get(), $item['event-finish'], $dformat_short)) : day_short_translate(datetime_convert('UTC', 'UTC', $item['event-finish'], $dformat_short)));
$end_time = (($item['event-adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $item['event-finish'], $tformat) : datetime_convert('UTC', 'UTC', $item['event-finish'], $tformat));
$dtend_dt = (($item['event-adjust']) ? day_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat)) : day_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat)));
$dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s'));
$end_short = (($item['event-adjust']) ? day_short_translate(Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short)) : day_short_translate(Temporal::convert($item['event-finish'], 'UTC', 'UTC', $dformat_short)));
$end_time = (($item['event-adjust']) ? Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) : Temporal::convert($item['event-finish'], 'UTC', 'UTC', $tformat));
// 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;

23
include/items.php

@ -2,28 +2,29 @@
/**
* @file include/items.php
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
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\Model\Item;
use Friendica\Model\Conversation;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Feed;
use Friendica\Util\Network;
use Friendica\Protocol\OStatus;
use Friendica\Util\ParseUrl;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php';
require_once 'include/tags.php';
@ -415,7 +416,7 @@ function drop_item($id) {
/* arrange the list in years */
function list_post_dates($uid, $wall) {
$dnow = datetime_convert('',date_default_timezone_get(), 'now','Y-m-d');
$dnow = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y-m-d');
$dthen = Item::firstPostDate($uid, $wall);
if (!$dthen) {
@ -436,14 +437,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 = datetime_convert('', '', $dstart, 'Y-m-d');
$end_month = datetime_convert('', '', $dend, 'Y-m-d');
$str = day_translate(datetime_convert('', '', $dnow, 'F'));
$start_month = Temporal::convert($dstart, 'UTC', 'UTC', 'Y-m-d');
$end_month = Temporal::convert($dend, 'UTC', 'UTC', 'Y-m-d');
$str = day_translate(Temporal::convert($dnow, 'UTC', 'UTC', 'F'));
if (!$ret[$dyear]) {
$ret[$dyear] = [];
}
$ret[$dyear][] = [$str, $end_month, $start_month];
$dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d');
$dnow = Temporal::convert($dnow . ' -1 month', 'UTC', 'UTC', 'Y-m-d');
}
return $ret;
}
@ -473,7 +474,7 @@ function posted_date_widget($url, $uid, $wall) {
return $o;
}
$cutoff_year = intval(datetime_convert('',date_default_timezone_get(), 'now', 'Y')) - $visible_years;
$cutoff_year = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y')) - $visible_years;
$cutoff = ((array_key_exists($cutoff_year, $ret))? true : false);
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),[

7
include/security.php

@ -2,7 +2,7 @@
/**
* @file include/security.php
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -10,6 +10,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Util\Temporal;
/**
* @brief Calculate the hash that is needed for the "Friendica" cookie
@ -141,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' => datetime_convert()], ['uid' => $_SESSION['uid']]);
dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user
dba::update('user', ['login_date' => datetime_convert()],
dba::update('user', ['login_date' => Temporal::convert()],
['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
}

6
include/text.php

@ -2,6 +2,7 @@
/**
* @file include/text.php
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
@ -15,6 +16,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Model\Term;
use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once "mod/proxy.php";
require_once "include/conversation.php";
@ -721,7 +723,7 @@ function logger($msg, $level = 0) {
$callers = debug_backtrace();
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
datetime_convert('UTC', 'UTC', 'now', 'Y-m-d\TH:i:s\Z'),
Temporal::convert('now', 'UTC', 'UTC', 'Y-m-d\TH:i:s\Z'),
$process_id,
$LOGGER_LEVELS[$level],
basename($callers[0]['file']),
@ -787,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",
datetime_convert(),
Temporal::convert(),
$process_id,
basename($callers[0]['file']),
$callers[0]['line'],

5
mod/admin.php

@ -17,9 +17,10 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Util\Temporal;
require_once 'include/enotify.php';
require_once 'include/text.php';
@ -739,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(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) {
} elseif ((strtotime(Temporal::convert()) - 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

@ -5,6 +5,7 @@
* This calendar is for profile visitors and contains only the events
* of the profile owner
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
@ -16,6 +17,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal;
require_once 'include/event.php';
@ -150,8 +152,8 @@ function cal_content(App $a)
// The view mode part is similiar to /mod/events.php
if ($mode == 'view') {
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
$thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
$thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm');
if (!$y) {
$y = intval($thisyear);
}
@ -201,11 +203,11 @@ function cal_content(App $a)
}
}
$start = datetime_convert('UTC', 'UTC', $start);
$finish = datetime_convert('UTC', 'UTC', $finish);
$start = Temporal::convert($start);
$finish = Temporal::convert($finish);
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
$adjust_start = Temporal::convert($start, date_default_timezone_get());
$adjust_finish = Temporal::convert($finish, date_default_timezone_get());
// put the event parametes in an array so we can better transmit them
$event_params = [
@ -229,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']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
$j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
if (!x($links, $j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}

4
mod/contacts.php

@ -2,6 +2,7 @@
/**
* @file mod/contacts.php
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
@ -16,6 +17,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
require_once 'mod/proxy.php';
@ -538,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') : datetime_convert('UTC', date_default_timezone_get(), $contact['last-update'], 'D, j M Y, g:i A'));
$last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::convert($contact['last-update'], date_default_timezone_get(), 'UTC', '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"));

13
mod/dfrn_confirm.php

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

12
mod/dfrn_request.php

@ -11,6 +11,7 @@
* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -19,11 +20,12 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\User;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
require_once 'include/enotify.php';
@ -135,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()),
datetime_convert(),
Temporal::convert(),
dbesc($dfrn_url),
dbesc(normalise_link($dfrn_url)),
$parms['addr'],
@ -239,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(datetime_convert('UTC', 'UTC', 'now - 24 hours')),
dbesc(Temporal::convert('now - 24 hours')),
intval($uid)
);
if (DBM::is_result($r) && count($r) > $maxreq) {
@ -380,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(datetime_convert()),
dbesc(Temporal::convert()),
$parms['url'],
dbesc(normalise_link($url)),
$parms['addr'],
@ -428,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(datetime_convert())
dbesc(Temporal::convert())
);
}

47
mod/events.php

@ -3,15 +3,16 @@
* @file mod/events.php
* @brief The events module
*/
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php';
require_once 'include/datetime.php';
@ -75,14 +76,14 @@ function events_post(App $a) {
}
if ($adjust) {
$start = datetime_convert(date_default_timezone_get(), 'UTC', $start);
$start = Temporal::convert($start, 'UTC', date_default_timezone_get());
if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(), 'UTC', $finish);
$finish = Temporal::convert($finish, 'UTC', date_default_timezone_get());
}
} else {
$start = datetime_convert('UTC', 'UTC', $start);
$start = Temporal::convert($start);
if (! $nofinish) {
$finish = datetime_convert('UTC', 'UTC', $finish);
$finish = Temporal::convert($finish);
}
}
@ -275,8 +276,8 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php
if ($mode == 'view') {
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
$thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
$thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm');
if (! $y) {
$y = intval($thisyear);
}
@ -322,11 +323,11 @@ function events_content(App $a) {
}
}
$start = datetime_convert('UTC', 'UTC', $start);
$finish = datetime_convert('UTC', 'UTC', $finish);
$start = Temporal::convert($start);
$finish = Temporal::convert($finish);
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
$adjust_start = Temporal::convert($start, date_default_timezone_get());
$adjust_finish = Temporal::convert($finish, date_default_timezone_get());
// put the event parametes in an array so we can better transmit them
$event_params = [
@ -350,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']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
$j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j'));
if (! x($links,$j)) {
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
}
@ -464,19 +465,19 @@ function events_content(App $a) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm');
$sday = datetime_convert('UTC', $tz, $sdt, 'd');
$syear = Temporal::convert($sdt, $tz, 'UTC', 'Y');
$smonth = Temporal::convert($sdt, $tz, 'UTC', 'm');
$sday = Temporal::convert($sdt, $tz, 'UTC', 'd');
$shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0);
$sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0);
$shour = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'H') : 0);
$sminute = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'i') : 0);
$fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
$fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
$fday = datetime_convert('UTC', $tz, $fdt, 'd');
$fyear = Temporal::convert($fdt, $tz, 'UTC', 'Y');
$fmonth = Temporal::convert($fdt, $tz, 'UTC', 'm');
$fday = Temporal::convert($fdt, $tz, 'UTC', 'd');
$fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0);
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$fhour = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'H') : 0);
$fminute = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'i') : 0);
require_once 'include/acl_selectors.php' ;

4
mod/fsuggest.php

@ -2,10 +2,12 @@
/**
* @file mod/fsuggest.php
*/
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Util\Temporal;
function fsuggest_post(App $a)
{
@ -50,7 +52,7 @@ function fsuggest_post(App $a)
dbesc($r[0]['request']),
dbesc($r[0]['photo']),
dbesc($hash),
dbesc(datetime_convert())
dbesc(Temporal::convert())
);
$r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1",
dbesc($hash),

4
mod/install.php

@ -2,6 +2,7 @@
/**
* @file mod/install.php
*/
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
@ -9,6 +10,7 @@ use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Object\Image;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
$install_wizard_pass = 1;
@ -279,7 +281,7 @@ function install_content(App $a) {
'$adminmail' => ['adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'],
'$timezone' => field_timezone('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''),
'$timezone' => Temporal::getTimezoneField('timezone', L10n::t('Please select a default timezone for your website'), $timezone, ''),
'$language' => ['language', L10n::t('System Language:'), 'en', L10n::t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices],
'$baseurl' => System::baseUrl(),

4
mod/invite.php

@ -5,12 +5,14 @@
* Send email invitations to join social network
*
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Protocol\Email;
use Friendica\Util\Temporal;
function invite_post(App $a)
{
@ -60,7 +62,7 @@ function invite_post(App $a)
$r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ",
dbesc($code),
dbesc(datetime_convert())
dbesc(Temporal::convert())
);
if (! is_site_admin()) {

17
mod/item.php

@ -14,6 +14,7 @@
* All of these become an "item" which is our basic unit of
* information.
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Addon;
@ -25,10 +26,10 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Util\Emailer;
use Friendica\Util\Temporal;
require_once 'include/enotify.php';
require_once 'include/tags.php';
@ -600,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'] = datetime_convert();
$datarray['edited'] = datetime_convert();
$datarray['commented'] = datetime_convert();
$datarray['received'] = datetime_convert();
$datarray['changed'] = datetime_convert();
$datarray['created'] = Temporal::convert();
$datarray['edited'] = Temporal::convert();
$datarray['commented'] = Temporal::convert();
$datarray['received'] = Temporal::convert();
$datarray['changed'] = Temporal::convert();
$datarray['extid'] = $extid;
$datarray['guid'] = $guid;
$datarray['uri'] = $uri;
@ -708,8 +709,8 @@ function item_post(App $a) {
'file' => $datarray['file'],
'rendered-html' => $datarray['rendered-html'],
'rendered-hash' => $datarray['rendered-hash'],
'edited' => datetime_convert(),
'changed' => datetime_convert()];
'edited' => Temporal::convert(),
'changed' => Temporal::convert()];
Item::update($fields, ['id' => $post_id]);

6
mod/localtime.php

@ -2,9 +2,11 @@
/**
* @file mod/localtime.php
*/
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Util\Temporal;
require_once 'include/datetime.php';
@ -18,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'] = datetime_convert('UTC', $_POST['timezone'], $t, $bd_format);
$a->data['mod-localtime'] = Temporal::convert($t, $_POST['timezone'], 'UTC', $bd_format);
}
}
@ -50,7 +52,7 @@ function localtime_content(App $a)
$o .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
$o .= select_timezone(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles');
$o .= Temporal::getTimezoneSelect(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles');
$o .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';

5
mod/lostpass.php

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

6
mod/message.php

@ -2,6 +2,7 @@
/**
* @file mod/message.php
*/
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Smilies;
@ -10,6 +11,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
use Friendica\Util\Temporal;
require_once 'include/acl_selectors.php';
require_once 'include/conversation.php';
@ -395,7 +397,7 @@ function message_content(App $a)
'body' => $body_e,
'delete' => L10n::t('Delete message'),
'to_name' => $to_name_e,
'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'),
'date' => Temporal::convert($message['created'], date_default_timezone_get(), 'UTC', 'D, d M Y - g:i A'),
'ago' => relative_date($message['created']),
];
@ -496,7 +498,7 @@ function render_messages(array $msg, $t)
'$delete' => L10n::t('Delete conversation'),
'$body' => $body_e,
'$to_name' => $to_name_e,
'$date' => datetime_convert('UTC', date_default_timezone_get(), $rr['mailcreated'], L10n::t('D, d M Y - g:i A')),
'$date' => Temporal::convert($rr['mailcreated'], date_default_timezone_get(), 'UTC', 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']),

14
mod/network.php

@ -3,14 +3,15 @@
/**
* @file mod/network.php
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
@ -18,6 +19,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Util\Temporal;
require_once 'include/conversation.php';
require_once 'include/items.php';
@ -679,11 +681,11 @@ function networkThreadedView(App $a, $update = 0)
if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ",
dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get()))));
}
if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ",
dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get()))));
}
$sql_order = '';
@ -788,8 +790,8 @@ function networkThreadedView(App $a, $update = 0)
$top_limit = current($r)['order_date'];
$bottom_limit = end($r)['order_date'];
} else {
$top_limit = datetime_convert();
$bottom_limit = datetime_convert();
$top_limit = Temporal::convert();
$bottom_limit = Temporal::convert();
}
// When checking for updates we need to fetch from the newest date to the newest date before
@ -802,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 = datetime_convert();
$top_limit = Temporal::convert();
}
$items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item`

21
mod/photos.php

@ -2,13 +2,14 @@
/**
* @file mod/photos.php
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;