Merge pull request #4387 from MrPetovan/task/3878-move-datetime-to-src

Move include/datetime to src/ - Part 2
This commit is contained in:
Michael Vogel 2018-02-04 21:05:27 +01:00 committed by GitHub
commit dad58e0f6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 63 additions and 136 deletions

View file

@ -32,7 +32,6 @@ use Friendica\Model\Contact;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
require_once 'include/text.php'; require_once 'include/text.php';
require_once 'include/datetime.php';
define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Asparagus'); define('FRIENDICA_CODENAME', 'Asparagus');

View file

@ -41,7 +41,6 @@ use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/datetime.php';
require_once 'include/conversation.php'; require_once 'include/conversation.php';
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
require_once 'mod/share.php'; require_once 'mod/share.php';

View file

@ -15,9 +15,10 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Object\Post; use Friendica\Object\Post;
use Friendica\Util\XML;
use Friendica\Object\Thread; use Friendica\Object\Thread;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
require_once "include/bbcode.php"; require_once "include/bbcode.php";
require_once "include/acl_selectors.php"; require_once "include/acl_selectors.php";
@ -791,7 +792,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'folders' => $folders, 'folders' => $folders,
'text' => strip_tags($body_e), 'text' => strip_tags($body_e),
'localtime' => DateTimeFormat::local($item['created'], 'r'), 'localtime' => DateTimeFormat::local($item['created'], 'r'),
'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])), 'ago' => (($item['app']) ? L10n::t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])),
'location' => $location_e, 'location' => $location_e,
'indent' => '', 'indent' => '',
'owner_name' => $owner_name_e, 'owner_name' => $owner_name_e,
@ -1166,7 +1167,7 @@ function builtin_activity_puller($item, &$conv_responses) {
* @param array $arr = array of pre-linked names of likers/dislikers * @param array $arr = array of pre-linked names of likers/dislikers
* @param string $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe' * @param string $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
* @param int $id = item id * @param int $id = item id
* @return formatted text * @return string formatted text
*/ */
function format_like($cnt, array $arr, $type, $id) { function format_like($cnt, array $arr, $type, $id) {
$o = ''; $o = '';

View file

@ -1,49 +0,0 @@
<?php
/**
* @file include/datetime.php
* @brief Some functions for date and time related tasks.
*/
use Friendica\Model\Contact;
use Friendica\Util\Temporal;
function dob($dob) {
return Temporal::getDateofBirthField($dob);
}
function datesel($min, $max, $default, $id = 'datepicker') {
return Temporal::getDateField($min, $max, $default, $id);
}
function timesel($h, $m, $id = 'timepicker') {
return Temporal::getTimeField($h, $m, $id);
}
function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
return Temporal::getDateTimeField($min, $max, $default, $label, $id, $pickdate, $picktime, $minfrom, $maxfrom, $required);
}
function relative_date($posted_date, $format = null) {
return Temporal::getRelativeDate($posted_date, $format);
}
function age($dob, $owner_tz = '', $viewer_tz = '') {
return Temporal::getAgeByTimezone($dob, $owner_tz, $viewer_tz);
}
function get_dim($y, $m) {
return Temporal::getDaysInMonth($y, $m);
}
function get_first_dim($y,$m) {
return Temporal::getFirstDayInMonth($y, $m);
}
function cal($y = 0, $m = 0, $links = null, $class = '')
{
return Temporal::getCalendarTable($y, $m, $links, $class);
}
function update_contact_birthdays() {
return Contact::updateBirthdays();
}

View file

@ -6,8 +6,6 @@ use Friendica\Database\DBM;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
require_once('include/datetime.php');
/** /**
* @class MySQL database class * @class MySQL database class
* *

View file

@ -16,7 +16,6 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/datetime.php';
require_once 'include/conversation.php'; require_once 'include/conversation.php';
function format_event_html($ev, $simple = false) { function format_event_html($ev, $simple = false) {
@ -238,7 +237,6 @@ function event_delete($event_id) {
*/ */
function event_store($arr) { function event_store($arr) {
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';

View file

@ -17,6 +17,7 @@ use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/tags.php'; require_once 'include/tags.php';
@ -428,7 +429,7 @@ function list_post_dates($uid, $wall) {
while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) { while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dyear = intval(substr($dnow, 0, 4)); $dyear = intval(substr($dnow, 0, 4));
$dstart = substr($dnow, 0, 8) . '01'; $dstart = substr($dnow, 0, 8) . '01';
$dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5))); $dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5)));
$start_month = DateTimeFormat::utc($dstart, 'Y-m-d'); $start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
$end_month = DateTimeFormat::utc($dend, 'Y-m-d'); $end_month = DateTimeFormat::utc($dend, 'Y-m-d');
$str = day_translate(DateTimeFormat::utc($dnow, 'F')); $str = day_translate(DateTimeFormat::utc($dnow, 'F'));

View file

@ -21,6 +21,7 @@ use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Login; use Friendica\Module\Login;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
require_once 'include/enotify.php'; require_once 'include/enotify.php';
require_once 'include/text.php'; require_once 'include/text.php';
@ -1648,13 +1649,13 @@ function admin_page_users(App $a)
L10n::t('Automatic Friend Account') L10n::t('Automatic Friend Account')
]; ];
$e['page-flags'] = $accounts[$e['page-flags']]; $e['page-flags'] = $accounts[$e['page-flags']];
$e['register_date'] = relative_date($e['register_date']); $e['register_date'] = Temporal::getRelativeDate($e['register_date']);
$e['login_date'] = relative_date($e['login_date']); $e['login_date'] = Temporal::getRelativeDate($e['login_date']);
$e['lastitem_date'] = relative_date($e['lastitem_date']); $e['lastitem_date'] = Temporal::getRelativeDate($e['lastitem_date']);
//$e['is_admin'] = ($e['email'] === $a->config['admin_email']); //$e['is_admin'] = ($e['email'] === $a->config['admin_email']);
$e['is_admin'] = in_array($e['email'], $adminlist); $e['is_admin'] = in_array($e['email'], $adminlist);
$e['is_deletable'] = (intval($e['uid']) != local_user()); $e['is_deletable'] = (intval($e['uid']) != local_user());
$e['deleted'] = ($e['account_removed'] ? relative_date($e['account_expires_on']) : False); $e['deleted'] = ($e['account_removed'] ? Temporal::getRelativeDate($e['account_expires_on']) : False);
return $e; return $e;
}; };
$users = array_map($_setup_users, $users); $users = array_map($_setup_users, $users);

View file

@ -18,6 +18,7 @@ use Friendica\Model\Group;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
require_once 'include/event.php'; require_once 'include/event.php';
@ -188,7 +189,7 @@ function cal_content(App $a)
$prevyear --; $prevyear --;
} }
$dim = get_dim($y, $m); $dim = Temporal::getDaysInMonth($y, $m);
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0); $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59); $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
@ -274,7 +275,7 @@ function cal_content(App $a)
'$view' => L10n::t('View'), '$view' => L10n::t('View'),
'$previous' => [System::baseUrl() . "/events/$prevyear/$prevmonth", L10n::t('Previous'), '', ''], '$previous' => [System::baseUrl() . "/events/$prevyear/$prevmonth", L10n::t('Previous'), '', ''],
'$next' => [System::baseUrl() . "/events/$nextyear/$nextmonth", L10n::t('Next'), '', ''], '$next' => [System::baseUrl() . "/events/$nextyear/$nextmonth", L10n::t('Next'), '', ''],
'$calendar' => cal($y, $m, $links, ' eventcal'), '$calendar' => Temporal::getCalendarTable($y, $m, $links, ' eventcal'),
'$events' => $events, '$events' => $events,
"today" => L10n::t("today"), "today" => L10n::t("today"),
"month" => L10n::t("month"), "month" => L10n::t("month"),

View file

@ -13,9 +13,9 @@ use Friendica\Database\DBM;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'include/datetime.php';
require_once 'include/event.php'; require_once 'include/event.php';
require_once 'include/items.php'; require_once 'include/items.php';
@ -310,7 +310,7 @@ function events_content(App $a) {
$prevyear --; $prevyear --;
} }
$dim = get_dim($y, $m); $dim = Temporal::getDaysInMonth($y, $m);
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0); $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59); $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
@ -395,7 +395,7 @@ function events_content(App $a) {
'$new_event' => [System::baseUrl() . '/events/new', L10n::t('Create New Event'), '', ''], '$new_event' => [System::baseUrl() . '/events/new', L10n::t('Create New Event'), '', ''],
'$previous' => [System::baseUrl() . '/events/$prevyear/$prevmonth', L10n::t('Previous'), '', ''], '$previous' => [System::baseUrl() . '/events/$prevyear/$prevmonth', L10n::t('Previous'), '', ''],
'$next' => [System::baseUrl() . '/events/$nextyear/$nextmonth', L10n::t('Next'), '', ''], '$next' => [System::baseUrl() . '/events/$nextyear/$nextmonth', L10n::t('Next'), '', ''],
'$calendar' => cal($y, $m, $links, ' eventcal'), '$calendar' => Temporal::getCalendarTable($y, $m, $links, ' eventcal'),
'$events' => $events, '$events' => $events,
@ -510,11 +510,11 @@ function events_content(App $a) {
'$title' => L10n::t('Event details'), '$title' => L10n::t('Event details'),
'$desc' => L10n::t('Starting date and Title are required.'), '$desc' => L10n::t('Starting date and Title are required.'),
'$s_text' => L10n::t('Event Starts:') . ' <span class="required" title="' . L10n::t('Required') . '">*</span>', '$s_text' => L10n::t('Event Starts:') . ' <span class="required" title="' . L10n::t('Required') . '">*</span>',
'$s_dsel' => datetimesel(new DateTime(), DateTime::createFromFormat('Y', $syear+5), DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), L10n::t('Event Starts:'), 'start_text', true, true, '', '', true), '$s_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $syear+5), DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"), L10n::t('Event Starts:'), 'start_text', true, true, '', '', true),
'$n_text' => L10n::t('Finish date/time is not known or not relevant'), '$n_text' => L10n::t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked, '$n_checked' => $n_checked,
'$f_text' => L10n::t('Event Finishes:'), '$f_text' => L10n::t('Event Finishes:'),
'$f_dsel' => datetimesel(new DateTime(), DateTime::createFromFormat('Y', $fyear+5), DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), L10n::t('Event Finishes:'), 'finish_text', true, true, 'start_text'), '$f_dsel' => Temporal::getDateTimeField(new DateTime(), DateTime::createFromFormat('Y', $fyear+5), DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"), L10n::t('Event Finishes:'), 'finish_text', true, true, 'start_text'),
'$a_text' => L10n::t('Adjust for viewer timezone'), '$a_text' => L10n::t('Adjust for viewer timezone'),
'$a_checked' => $a_checked, '$a_checked' => $a_checked,
'$d_text' => L10n::t('Description:'), '$d_text' => L10n::t('Description:'),

View file

@ -253,7 +253,6 @@ function install_content(App $a) {
return $o; return $o;
}; break; }; break;
case 3: { // Site settings case 3: { // Site settings
require_once('include/datetime.php');
$dbhost = ((x($_POST, 'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'); $dbhost = ((x($_POST, 'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost');
$dbuser = notags(trim($_POST['dbuser'])); $dbuser = notags(trim($_POST['dbuser']));
$dbpass = notags(trim($_POST['dbpass'])); $dbpass = notags(trim($_POST['dbpass']));

View file

@ -6,10 +6,9 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
require_once 'include/datetime.php';
function localtime_post(App $a) function localtime_post(App $a)
{ {
$t = $_REQUEST['time']; $t = $_REQUEST['time'];

View file

@ -11,7 +11,6 @@ use Friendica\Model\User;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
require_once 'boot.php'; require_once 'boot.php';
require_once 'include/datetime.php';
require_once 'include/enotify.php'; require_once 'include/enotify.php';
require_once 'include/text.php'; require_once 'include/text.php';

View file

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

View file

@ -2,13 +2,15 @@
/** /**
* @file mod/notify.php * @file mod/notify.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\Core\NotificationsManager;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Module\Login;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Module\Login;
use Friendica\Util\Temporal;
function notify_init(App $a) function notify_init(App $a)
{ {
@ -68,7 +70,7 @@ function notify_content(App $a)
'$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'], '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
'$item_image' => $it['photo'], '$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])), '$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date']) '$item_when' => Temporal::getRelativeDate($it['date'])
]); ]);
} }
} else { } else {

View file

@ -22,6 +22,7 @@ use Friendica\Object\Image;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Temporal;
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/acl_selectors.php'; require_once 'include/acl_selectors.php';
@ -1622,7 +1623,7 @@ function photos_content(App $a)
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
'$title' => $title_e, '$title' => $title_e,
'$body' => $body_e, '$body' => $body_e,
'$ago' => relative_date($item['created']), '$ago' => Temporal::getRelativeDate($item['created']),
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
'$drop' => $drop, '$drop' => $drop,
'$comment' => $comment '$comment' => $comment

View file

@ -15,9 +15,9 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/datetime.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
require_once 'mod/proxy.php'; require_once 'mod/proxy.php';
require_once 'include/enotify.php'; require_once 'include/enotify.php';
@ -370,7 +370,7 @@ function ping_init(App $a)
'name' => $notif['name'], 'name' => $notif['name'],
'url' => $notif['url'], 'url' => $notif['url'],
'photo' => $notif['photo'], 'photo' => $notif['photo'],
'date' => relative_date($notif['date']), 'date' => Temporal::getRelativeDate($notif['date']),
'message' => $notif['message'], 'message' => $notif['message'],
'seen' => $notif['seen'], 'seen' => $notif['seen'],
'timestamp' => strtotime($local_time) 'timestamp' => strtotime($local_time)

View file

@ -15,10 +15,11 @@ use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Model\Profile;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
function profiles_init(App $a) { function profiles_init(App $a) {
@ -714,14 +715,14 @@ function profiles_content(App $a) {
'$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . L10n::t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""), '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . L10n::t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
'$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']], '$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']],
'$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']], '$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']],
'$dob' => dob($r[0]['dob']), '$dob' => Temporal::getDateofBirthField($r[0]['dob']),
'$hide_friends' => $hide_friends, '$hide_friends' => $hide_friends,
'$address' => ['address', L10n::t('Street Address:'), $r[0]['address']], '$address' => ['address', L10n::t('Street Address:'), $r[0]['address']],
'$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']], '$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']],
'$region' => ['region', L10n::t('Region/State:'), $r[0]['region']], '$region' => ['region', L10n::t('Region/State:'), $r[0]['region']],
'$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']], '$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']],
'$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']], '$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
'$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''), '$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . Temporal::getAgeByTimezone($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
'$gender' => ContactSelector::gender($r[0]['gender']), '$gender' => ContactSelector::gender($r[0]['gender']),
'$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
'$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')], '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],

View file

@ -10,8 +10,6 @@ use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype; use Friendica\Util\Mimetype;
require_once 'include/datetime.php';
function wall_attach_post(App $a) { function wall_attach_post(App $a) {
$r_json = (x($_GET,'response') && $_GET['response']=='json'); $r_json = (x($_GET,'response') && $_GET['response']=='json');

View file

@ -14,11 +14,11 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use Friendica\Util\XML; use Friendica\Util\XML;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
require_once 'include/datetime.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';
/** /**
@ -45,7 +45,7 @@ class NotificationsManager extends BaseObject
foreach ($notes as $n) { foreach ($notes as $n) {
$local_time = DateTimeFormat::local($n['date']); $local_time = DateTimeFormat::local($n['date']);
$n['timestamp'] = strtotime($local_time); $n['timestamp'] = strtotime($local_time);
$n['date_rel'] = relative_date($n['date']); $n['date_rel'] = Temporal::getRelativeDate($n['date']);
$n['msg_html'] = bbcode($n['msg'], false, false, false, false); $n['msg_html'] = bbcode($n['msg'], false, false, false, false);
$n['msg_plain'] = explode("\n", trim(html2plain($n['msg_html'], 0)))[0]; $n['msg_plain'] = explode("\n", trim(html2plain($n['msg_html'], 0)))[0];
@ -245,7 +245,7 @@ class NotificationsManager extends BaseObject
$default_item_url = $it['url']; $default_item_url = $it['url'];
$default_item_text = strip_tags(bbcode($it['msg'])); $default_item_text = strip_tags(bbcode($it['msg']));
$default_item_when = DateTimeFormat::local($it['date'], 'r'); $default_item_when = DateTimeFormat::local($it['date'], 'r');
$default_item_ago = relative_date($it['date']); $default_item_ago = Temporal::getRelativeDate($it['date']);
break; break;
case 'home': case 'home':
@ -255,7 +255,7 @@ class NotificationsManager extends BaseObject
$default_item_url = $it['author-link']; $default_item_url = $it['author-link'];
$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']); $default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
$default_item_when = DateTimeFormat::local($it['created'], 'r'); $default_item_when = DateTimeFormat::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']); $default_item_ago = Temporal::getRelativeDate($it['created']);
break; break;
default: default:
@ -267,7 +267,7 @@ class NotificationsManager extends BaseObject
? L10n::t("%s created a new post", $it['author-name']) ? L10n::t("%s created a new post", $it['author-name'])
: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname'])); : L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
$default_item_when = DateTimeFormat::local($it['created'], 'r'); $default_item_when = DateTimeFormat::local($it['created'], 'r');
$default_item_ago = relative_date($it['created']); $default_item_ago = Temporal::getRelativeDate($it['created']);
} }
// Transform the different types of notification in an usable array // Transform the different types of notification in an usable array

View file

@ -1388,7 +1388,7 @@ class Contact extends BaseObject
`blocked`, `readonly`, `pending`, `writable`) `blocked`, `readonly`, `pending`, `writable`)
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)", VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)",
intval($importer['uid']), intval($importer['uid']),
dbesc(datetime_convert()), dbesc(DateTimeFormat::utcNow()),
dbesc($url), dbesc($url),
dbesc(normalise_link($url)), dbesc(normalise_link($url)),
dbesc($name), dbesc($name),
@ -1418,7 +1418,7 @@ class Contact extends BaseObject
if (is_array($contact_record)) { if (is_array($contact_record)) {
dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'], dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
'blocked' => false, 'knowyou' => false, 'blocked' => false, 'knowyou' => false,
'hash' => $hash, 'datetime' => datetime_convert()]); 'hash' => $hash, 'datetime' => DateTimeFormat::utcNow()]);
} }
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']); Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);

View file

@ -19,7 +19,6 @@ use Friendica\Util\Network;
use dba; use dba;
use Exception; use Exception;
require_once 'include/datetime.php';
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/html2bbcode.php'; require_once 'include/html2bbcode.php';

View file

@ -14,7 +14,6 @@ use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/datetime.php';
/** /**
* Class to handle private messages * Class to handle private messages

View file

@ -9,7 +9,6 @@ use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/datetime.php';
/** /**
* @brief functions for interacting with a process * @brief functions for interacting with a process

View file

@ -19,6 +19,7 @@ use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Temporal;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -258,7 +259,7 @@ class Profile
* @param int $block * @param int $block
* @param boolean $show_connect Show connect link * @param boolean $show_connect Show connect link
* *
* @return HTML string suitable for sidebar inclusion * @return string HTML sidebar module
* *
* @note Returns empty string if passed $profile is wrong type or not populated * @note Returns empty string if passed $profile is wrong type or not populated
* *
@ -740,7 +741,7 @@ class Profile
if (!empty($a->profile['dob']) if (!empty($a->profile['dob'])
&& $a->profile['dob'] > '0001-01-01' && $a->profile['dob'] > '0001-01-01'
&& $age = age($a->profile['dob'], $a->profile['timezone'], '') && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'], '')
) { ) {
$profile['age'] = [L10n::t('Age:'), $age]; $profile['age'] = [L10n::t('Age:'), $age];
} }
@ -755,7 +756,7 @@ class Profile
} }
if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) { if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
$profile['howlong'] = relative_date($a->profile['howlong'], L10n::t('for %1$d %2$s')); $profile['howlong'] = Temporal::getRelativeDate($a->profile['howlong'], L10n::t('for %1$d %2$s'));
} }
if ($a->profile['sexual']) { if ($a->profile['sexual']) {

View file

@ -10,7 +10,6 @@ use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/datetime.php';
class Queue class Queue
{ {

View file

@ -17,7 +17,6 @@ use Exception;
use LightOpenID; use LightOpenID;
require_once 'boot.php'; require_once 'boot.php';
require_once 'include/datetime.php';
require_once 'include/security.php'; require_once 'include/security.php';
require_once 'include/text.php'; require_once 'include/text.php';

View file

@ -14,6 +14,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -125,7 +126,7 @@ class Post extends BaseObject
$edited = [ $edited = [
'label' => L10n::t('This entry was edited'), 'label' => L10n::t('This entry was edited'),
'date' => DateTimeFormat::local($item['edited'], 'r'), 'date' => DateTimeFormat::local($item['edited'], 'r'),
'relative' => relative_date($item['edited']) 'relative' => Temporal::getRelativeDate($item['edited'])
]; ];
} }
$commentww = ''; $commentww = '';
@ -365,9 +366,9 @@ class Post extends BaseObject
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'title' => $title_e, 'title' => $title_e,
'localtime' => DateTimeFormat::local($item['created'], 'r'), 'localtime' => DateTimeFormat::local($item['created'], 'r'),
'ago' => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']), 'ago' => $item['app'] ? L10n::t('%s from %s', Temporal::getRelativeDate($item['created']), $item['app']) : Temporal::getRelativeDate($item['created']),
'app' => $item['app'], 'app' => $item['app'],
'created' => relative_date($item['created']), 'created' => Temporal::getRelativeDate($item['created']),
'lock' => $lock, 'lock' => $lock,
'location' => $location_e, 'location' => $location_e,
'indent' => $indent, 'indent' => $indent,

View file

@ -34,7 +34,6 @@ use SimpleXMLElement;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/bb2diaspora.php'; require_once 'include/bb2diaspora.php';
require_once 'include/datetime.php';
/** /**
* @brief This class contain functions to create and send Diaspora XML files * @brief This class contain functions to create and send Diaspora XML files

View file

@ -23,7 +23,6 @@ use DOMXPath;
use Exception; use Exception;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/datetime.php';
require_once 'include/html2bbcode.php'; require_once 'include/html2bbcode.php';
class PortableContact class PortableContact

View file

@ -122,7 +122,7 @@ class DateTimeFormat
try { try {
$d = new DateTime($s, $from_obj); $d = new DateTime($s, $from_obj);
} catch (Exception $e) { } catch (Exception $e) {
logger('datetime_convert: exception: ' . $e->getMessage()); logger('DateTimeFormat::convert: exception: ' . $e->getMessage());
$d = new DateTime('now', $from_obj); $d = new DateTime('now', $from_obj);
} }

View file

@ -135,7 +135,7 @@ class Temporal
$value = DateTimeFormat::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d'); $value = DateTimeFormat::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d');
} }
$age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); $age = (intval($value) ? self::getAgeByTimezone($value, $a->user["timezone"], $a->user["timezone"]) : "");
$tpl = get_markup_template("field_input.tpl"); $tpl = get_markup_template("field_input.tpl");
$o = replace_macros($tpl, $o = replace_macros($tpl,
@ -165,7 +165,7 @@ class Temporal
*/ */
public static function getDateField($min, $max, $default, $id = 'datepicker') public static function getDateField($min, $max, $default, $id = 'datepicker')
{ {
return datetimesel($min, $max, $default, '', $id, true, false, '', ''); return self::getDateTimeField($min, $max, $default, '', $id, true, false, '', '');
} }
/** /**
@ -179,7 +179,7 @@ class Temporal
*/ */
public static function getTimeField($h, $m, $id = 'timepicker') public static function getTimeField($h, $m, $id = 'timepicker')
{ {
return datetimesel(new DateTime(), new DateTime(), new DateTime("$h:$m"), '', $id, false, true); return self::getDateTimeField(new DateTime(), new DateTime(), new DateTime("$h:$m"), '', $id, false, true);
} }
/** /**
@ -393,7 +393,7 @@ class Temporal
* *
* @return string day 0 = Sunday through 6 = Saturday * @return string day 0 = Sunday through 6 = Saturday
*/ */
public static function getFirstDayInMonth($y, $m) private static function getFirstDayInMonth($y, $m)
{ {
$d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m)); $d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m));
@ -438,8 +438,8 @@ class Temporal
} }
$dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; $dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
$f = get_first_dim($y, $m); $f = self::getFirstDayInMonth($y, $m);
$l = get_dim($y, $m); $l = self::getDaysInMonth($y, $m);
$d = 1; $d = 1;
$dow = 0; $dow = 0;
$started = false; $started = false;

View file

@ -17,8 +17,6 @@ Class Cron {
public static function execute($parameter = '', $generation = 0) { public static function execute($parameter = '', $generation = 0) {
global $a; global $a;
require_once 'include/datetime.php';
// Poll contacts with specific parameters // Poll contacts with specific parameters
if (!empty($parameter)) { if (!empty($parameter)) {
self::pollContacts($parameter, $generation); self::pollContacts($parameter, $generation);

View file

@ -14,8 +14,6 @@ Class CronHooks {
public static function execute($hook = '') { public static function execute($hook = '') {
global $a; global $a;
require_once 'include/datetime.php';
if (($hook != '') && is_array($a->hooks) && array_key_exists("cron", $a->hooks)) { if (($hook != '') && is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
foreach ($a->hooks["cron"] as $single_hook) { foreach ($a->hooks["cron"] as $single_hook) {
if ($single_hook[1] == $hook) { if ($single_hook[1] == $hook) {

View file

@ -25,7 +25,6 @@ class CronJobs
{ {
global $a; global $a;
require_once 'include/datetime.php';
require_once 'mod/nodeinfo.php'; require_once 'mod/nodeinfo.php';
// No parameter set? So return // No parameter set? So return
@ -55,7 +54,7 @@ class CronJobs
} }
if ($command == 'update_contact_birthdays') { if ($command == 'update_contact_birthdays') {
update_contact_birthdays(); Contact::updateBirthdays();
return; return;
} }

View file

@ -18,7 +18,6 @@ use Friendica\Protocol\Email;
use dba; use dba;
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';

View file

@ -14,8 +14,6 @@ use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
require_once 'include/datetime.php';
class DiscoverPoCo { class DiscoverPoCo {
/// @todo Clean up this mess of a parameter hell and split it in several classes /// @todo Clean up this mess of a parameter hell and split it in several classes
public static function execute($command = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '') public static function execute($command = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '')

View file

@ -9,8 +9,8 @@ namespace Friendica\Worker;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Model\Item;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Item;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -19,7 +19,6 @@ class Expire {
public static function execute($param = '', $hook_name = '') { public static function execute($param = '', $hook_name = '') {
global $a; global $a;
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
Addon::loadHooks(); Addon::loadHooks();

View file

@ -6,14 +6,11 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
require_once 'include/datetime.php';
class GProbe { class GProbe {
public static function execute($url = '') public static function execute($url = '')
{ {

View file

@ -19,7 +19,6 @@ use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/html2plain.php'; require_once 'include/html2plain.php';
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';

View file

@ -4,18 +4,17 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Content\Text\BBCode;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Util\Temporal;
use Friendica\Util\DateTimeFormat;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
@ -25,7 +24,6 @@ class OnePoll
public static function execute($contact_id = 0, $command = '') { public static function execute($contact_id = 0, $command = '') {
global $a; global $a;
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
logger('start'); logger('start');

View file

@ -6,18 +6,16 @@ namespace Friendica\Worker;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Queue as QueueModel; use Friendica\Model\Queue as QueueModel;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\PortableContact; use Friendica\Protocol\PortableContact;
use Friendica\Protocol\Salmon; use Friendica\Protocol\Salmon;
use dba; use dba;
require_once 'include/dba.php'; require_once 'include/dba.php';
require_once 'include/datetime.php';
require_once 'include/items.php'; require_once 'include/items.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';