Refactor datetime_convert into Temporal::convert

- Changed parameter order to save space
- Refactor select_timezone into Temporal::getTimezoneSelect
- Refactor field_timezone into Temporal::getTimezoneField
This commit is contained in:
Hypolite Petovan 2018-01-24 21:08:45 -05:00
commit dc366bf1f7
62 changed files with 512 additions and 432 deletions

View file

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

View file

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

View file

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

View file

@ -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),

View file

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

View file

@ -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' ;

View file

@ -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),

View file

@ -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(),

View file

@ -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()) {

View file

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

View file

@ -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>';

View file

@ -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

View file

@ -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']),

View file

@ -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`

View file

@ -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;
use Friendica\Model\Contact;
@ -19,6 +20,8 @@ use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN;
use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/items.php';
require_once 'include/acl_selectors.php';
@ -288,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(datetime_convert()),
dbesc(Temporal::convert()),
dbesc($rr['parent-uri']),
intval($page_owner_uid)
);
@ -361,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(datetime_convert()),
dbesc(datetime_convert()),
dbesc(Temporal::convert()),
dbesc(Temporal::convert()),
dbesc($i[0]['uri']),
intval($page_owner_uid)
);
@ -399,7 +402,7 @@ function photos_post(App $a)
$resource_id = $a->argv[2];
if (!strlen($albname)) {
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
$albname = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
}
if (x($_POST,'rotate') !== false &&
@ -646,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(datetime_convert()),
dbesc(datetime_convert()),
dbesc(Temporal::convert()),
dbesc(Temporal::convert()),
intval($item_id),
intval($page_owner_uid)
);
@ -735,7 +738,7 @@ function photos_post(App $a)
if (strlen($newalbum)) {
$album = $newalbum;
} else {
$album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
$album = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y');
}
}
@ -1358,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=' . datetime_convert('','','','ymdhis'),
'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::convert('now', 'UTC', 'UTC', 'ymdhis'),
'height' => $hires['height'],
'width' => $hires['width'],
'album' => $hires['album'],

View file

@ -2,17 +2,19 @@
/**
* @file include/ping.php
*/
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
require_once 'include/datetime.php';
@ -223,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(datetime_convert('UTC', 'UTC', 'now + 7 days')),
dbesc(datetime_convert('UTC', 'UTC', 'now'))
dbesc(Temporal::convert('now + 7 days')),
dbesc(Temporal::convert('now'))
);
if (DBM::is_result($ev)) {
Cache::set($cachekey, $ev, CACHE_HOUR);
@ -235,7 +237,7 @@ function ping_init(App $a)
$all_events = count($ev);
if ($all_events) {
$str_now = datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d');
$str_now = Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d');
foreach ($ev as $x) {
$bd = false;
if ($x['type'] === 'birthday') {
@ -244,7 +246,7 @@ function ping_init(App $a)
} else {
$events ++;
}
if (datetime_convert('UTC', ((intval($x['adjust'])) ? $a->timezone : 'UTC'), $x['start'], 'Y-m-d') === $str_now) {
if (Temporal::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) {
$all_events_today ++;
if ($bd) {
$birthdays_today ++;
@ -360,7 +362,7 @@ function ping_init(App $a)
$notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO);
}
$local_time = datetime_convert('UTC', date_default_timezone_get(), $notif['date']);
$local_time = Temporal::convert($notif['date'], date_default_timezone_get());
$notifications[] = [
'id' => $notif['id'],

View file

@ -2,9 +2,10 @@
/**
* @file mod/profile.php
*/
use Friendica\App;
use Friendica\Content\Widget;
use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -15,6 +16,7 @@ use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal;
function profile_init(App $a)
{
@ -270,10 +272,10 @@ function profile_content(App $a, $update = 0)
}
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get()))));
}
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get()))));
}
// Belongs the profile page to a forum?

View file

@ -2,6 +2,7 @@
/**
* @file mod/profile_photo.php
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
@ -11,6 +12,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Object\Image;
use Friendica\Util\Temporal;
function profile_photo_init(App $a)
{
@ -128,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(datetime_convert()),
dbesc(Temporal::convert()),
intval(local_user())
);
@ -228,7 +230,7 @@ function profile_photo_content(App $a) {
);
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
dbesc(datetime_convert()),
dbesc(Temporal::convert()),
intval(local_user())
);

View file

@ -2,6 +2,7 @@
/**
* @file mod/profiles.php
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
@ -17,6 +18,7 @@ use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Model\Item;
use Friendica\Network\Probe;
use Friendica\Util\Temporal;
function profiles_init(App $a) {
@ -216,7 +218,7 @@ function profiles_post(App $a) {
$ignore_year = true;
$dob = substr($dob, 5);
}
$dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
$dob = Temporal::convert((($ignore_year) ? '1900-' . $dob : $dob), 'UTC', 'UTC', (($ignore_year) ? 'm-d' : 'Y-m-d'));
if ($ignore_year) {
$dob = '0000-' . $dob;
@ -250,7 +252,7 @@ function profiles_post(App $a) {
if (! strlen($howlong)) {
$howlong = NULL_DATE;
} else {
$howlong = datetime_convert(date_default_timezone_get(), 'UTC', $howlong);
$howlong = Temporal::convert($howlong, 'UTC', date_default_timezone_get());
}
// linkify the relationship target if applicable
@ -485,7 +487,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(datetime_convert()),
dbesc(Temporal::convert()),
intval(local_user())
);
$r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
@ -722,7 +724,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 ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))],
'$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::convert($r[0]['howlong'], date_default_timezone_get()))],
'$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.")],

View file

@ -11,6 +11,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -187,7 +188,7 @@ function proxy_init(App $a) {
die();
}
$fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => datetime_convert(), 'edited' => datetime_convert(),
$fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::convert(), 'edited' => Temporal::convert(),
'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];

View file

@ -5,6 +5,7 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
function post_var($name) {
return (x($_POST, $name)) ? notags(trim($_POST[$name])) : '';
@ -138,7 +139,7 @@ function pubsubhubbub_init(App $a) {
dbesc($hub_callback));
if ($subscribe) {
$last_update = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
$last_update = Temporal::convert();
$push_flag = 0;
// if we are just updating an old subscription, keep the

View file

@ -2,6 +2,7 @@
/**
* @file mod/register.php
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config;
@ -10,6 +11,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Model\User;
use Friendica\Util\Temporal;
require_once 'include/enotify.php';
require_once 'include/bbcode.php';
@ -116,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(datetime_convert()),
dbesc(Temporal::convert()),
intval($user['uid']),
dbesc($result['password']),
dbesc($lang),

View file

@ -18,6 +18,7 @@ use Friendica\Model\Group;
use Friendica\Model\User;
use Friendica\Protocol\Email;
use Friendica\Util\Network;
use Friendica\Util\Temporal;
function get_theme_config_file($theme)
{
@ -630,7 +631,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(datetime_convert()),
dbesc(Temporal::convert()),
intval(local_user())
);
}
@ -1210,7 +1211,7 @@ function settings_content(App $a)
'$h_basic' => L10n::t('Basic Settings'),
'$username' => ['username', L10n::t('Full Name:'), $username, ''],
'$email' => ['email', L10n::t('Email Address:'), $email, '', '', '', 'email'],
'$timezone' => ['timezone_select' , L10n::t('Your Timezone:'), select_timezone($timezone), ''],
'$timezone' => ['timezone_select' , L10n::t('Your Timezone:'), Temporal::getTimezoneSelect($timezone), ''],
'$language' => ['language', L10n::t('Your Language:'), $language, L10n::t('Set the language we use to show you friendica interface and to send you emails'), $lang_choices],
'$defloc' => ['defloc', L10n::t('Default Post Location:'), $defloc, ''],
'$allowloc' => ['allow_location', L10n::t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''],

View file

@ -2,6 +2,7 @@
/**
* @file mod/videos.php
*/
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Core\Config;
@ -13,6 +14,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
use Friendica\Util\Temporal;
require_once 'include/items.php';
require_once 'include/acl_selectors.php';
@ -168,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(datetime_convert()),
dbesc(datetime_convert()),
dbesc(Temporal::convert()),
dbesc(Temporal::convert()),
dbesc($i[0]['uri']),
intval(local_user())
);

View file

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