From 411a4004723b7822ad9484a57b5dcc4880449ef3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 3 Feb 2018 08:52:43 -0500 Subject: [PATCH 01/24] Move SMARTY3_TEMPLATE_FOLDER to FriendicaSmarty - Copy get_template_file into only class calling it --- src/Render/FriendicaSmarty.php | 14 +++++++------- src/Render/FriendicaSmartyEngine.php | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/Render/FriendicaSmarty.php b/src/Render/FriendicaSmarty.php index b147d7e81..278fe1f93 100644 --- a/src/Render/FriendicaSmarty.php +++ b/src/Render/FriendicaSmarty.php @@ -6,15 +6,15 @@ namespace Friendica\Render; use Smarty; -define('SMARTY3_TEMPLATE_FOLDER', 'templates'); - /** - * Description of FriendicaSmarty + * Friendica extension of the Smarty3 template engine * - * @author benlo + * @author Hypolite Petovan */ class FriendicaSmarty extends Smarty { + const SMARTY3_TEMPLATE_FOLDER = 'templates'; + public $filename; function __construct() @@ -26,12 +26,12 @@ class FriendicaSmarty extends Smarty // setTemplateDir can be set to an array, which Smarty will parse in order. // The order is thus very important here - $template_dirs = ['theme' => "view/theme/$theme/" . SMARTY3_TEMPLATE_FOLDER . "/"]; + $template_dirs = ['theme' => "view/theme/$theme/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; if (x($a->theme_info, "extends")) { - $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . SMARTY3_TEMPLATE_FOLDER . "/"]; + $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; } - $template_dirs = $template_dirs + ['base' => "view/" . SMARTY3_TEMPLATE_FOLDER . "/"]; + $template_dirs = $template_dirs + ['base' => "view/" . self::SMARTY3_TEMPLATE_FOLDER . "/"]; $this->setTemplateDir($template_dirs); $this->setCompileDir('view/smarty3/compiled/'); diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php index 6fd51cf5d..949ac58c8 100644 --- a/src/Render/FriendicaSmartyEngine.php +++ b/src/Render/FriendicaSmartyEngine.php @@ -6,8 +6,11 @@ namespace Friendica\Render; use Friendica\Core\Addon; -define('SMARTY3_TEMPLATE_FOLDER', 'templates'); - +/** + * Smarty implementation of the Friendica template engine interface + * + * @author Hypolite Petovan + */ class FriendicaSmartyEngine implements ITemplateEngine { static $name = "smarty3"; @@ -52,8 +55,26 @@ class FriendicaSmartyEngine implements ITemplateEngine public function getTemplateFile($file, $root = '') { $a = get_app(); - $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root); $template = new FriendicaSmarty(); + + // Make sure $root ends with a slash / + if ($root !== '' && substr($root, -1, 1) !== '/') { + $root = $root . '/'; + } + + $theme = current_theme(); + $filename = $template::SMARTY3_TEMPLATE_FOLDER . '/' . $file; + + if (file_exists("{$root}view/theme/$theme/$filename")) { + $template_file = "{$root}view/theme/$theme/$filename"; + } elseif (x($a->theme_info, 'extends') && file_exists(sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename))) { + $template_file = sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename); + } elseif (file_exists("{$root}/$filename")) { + $template_file = "{$root}/$filename"; + } else { + $template_file = "{$root}view/$filename"; + } + $template->filename = $template_file; return $template; From 7be49913d4ed915c5dc51b7994a1ca055d9e7eee Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 3 Feb 2018 08:52:55 -0500 Subject: [PATCH 02/24] Remove get_template_file function --- include/text.php | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/include/text.php b/include/text.php index 3244d7bb9..ab0d707e7 100644 --- a/include/text.php +++ b/include/text.php @@ -613,36 +613,6 @@ function get_markup_template($s, $root = '') { return $template; } - -/** - * - * @param App $a - * @param string $filename - * @param string $root - * @return string - */ -function get_template_file($a, $filename, $root = '') { - $theme = current_theme(); - - // Make sure $root ends with a slash / - if ($root !== '' && substr($root, -1, 1) !== '/') { - $root = $root . '/'; - } - - if (file_exists("{$root}view/theme/$theme/$filename")) { - $template_file = "{$root}view/theme/$theme/$filename"; - } elseif (x($a->theme_info, "extends") && file_exists(sprintf('%sview/theme/%s}/%s', $root, $a->theme_info["extends"], $filename))) { - $template_file = sprintf('%sview/theme/%s}/%s', $root, $a->theme_info["extends"], $filename); - } elseif (file_exists("{$root}/$filename")) { - $template_file = "{$root}/$filename"; - } else { - $template_file = "{$root}view/$filename"; - } - - return $template_file; -} - - /** * for html,xml parsing - let's say you've got * an attribute foobar="class1 class2 class3" From d478ef6c6d93f4b7f27b40ebe6b46af9759f415f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 24 Jan 2018 20:47:33 -0500 Subject: [PATCH 03/24] Add Util\Temporal to src - Map include/datetime functions to Temporal methods - Move update_contact_birthdays() to Model\Contact::updateBirthdays() --- include/datetime.php | 615 ++---------------------------------------- src/Model/Contact.php | 57 +++- src/Util/Temporal.php | 578 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 653 insertions(+), 597 deletions(-) create mode 100644 src/Util/Temporal.php diff --git a/include/datetime.php b/include/datetime.php index 9ff2f1ac6..ff7b2a9a6 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -4,633 +4,58 @@ * @brief Some functions for date and time related tasks. */ -use Friendica\Core\Config; -use Friendica\Core\L10n; -use Friendica\Core\PConfig; -use Friendica\Database\DBM; +use Friendica\Model\Contact; +use Friendica\Util\Temporal; -/** - * @brief Two-level sort for timezones. - * - * @param string $a - * @param string $b - * @return int - */ -function timezone_cmp($a, $b) { - if (strstr($a, '/') && strstr($b, '/')) { - if (L10n::t($a) == L10n::t($b)) { - return 0; - } - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; - } - - if (strstr($a, '/')) { - return -1; - } elseif (strstr($b, '/')) { - return 1; - } elseif (L10n::t($a) == L10n::t($b)) { - return 0; - } - - return (L10n::t($a) < L10n::t($b)) ? -1 : 1; -} - -/** - * @brief Emit a timezone selector grouped (primarily) by continent - * - * @param string $current Timezone - * @return string Parsed HTML output - */ function select_timezone($current = 'America/Los_Angeles') { - - $timezone_identifiers = DateTimeZone::listIdentifiers(); - - $o =''; - return $o; + return Temporal::getTimezoneSelect($current); } - - -/** - * @brief Generating a Timezone selector - * - * Return a select using 'field_select_raw' template, with timezones - * groupped (primarily) by continent - * arguments follow convetion as other field_* template array: - * 'name', 'label', $value, 'help' - * - * @param string $name Name of the selector - * @param string $label Label for the selector - * @param string $current Timezone - * @param string $help Help text - * - * @return string Parsed HTML - */ -function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){ - $options = select_timezone($current); - $options = str_replace('','', $options); - - $tpl = get_markup_template('field_select_raw.tpl'); - return replace_macros($tpl, [ - '$field' => [$name, $label, $current, $help, $options], - ]); - +function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help = ''){ + return Temporal::getTimezoneField($name, $label, $current, $help); } -/** - * @brief General purpose date parse/convert function. - * - * @param string $from Source timezone - * @param string $to Dest timezone - * @param string $s Some parseable date/time string - * @param string $fmt Output format recognised from php's DateTime class - * http://www.php.net/manual/en/datetime.format.php - * - * @return string Formatted date according to given format - */ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") { - - // Defaults to UTC if nothing is set, but throws an exception if set to empty string. - // Provide some sane defaults regardless. - - if ($from === '') { - $from = 'UTC'; - } - if ($to === '') { - $to = 'UTC'; - } - if ( ($s === '') || (! is_string($s)) ) { - $s = 'now'; - } - - /* - * Slight hackish adjustment so that 'zero' datetime actually returns what is intended - * otherwise we end up with -0001-11-30 ... - * add 32 days so that we at least get year 00, and then hack around the fact that - * months and days always start with 1. - */ - - if (substr($s,0,10) <= '0001-01-01') { - $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); - return str_replace('1','0',$d->format($fmt)); - } - - try { - $from_obj = new DateTimeZone($from); - } catch (Exception $e) { - $from_obj = new DateTimeZone('UTC'); - } - - try { - $d = new DateTime($s, $from_obj); - } catch (Exception $e) { - logger('datetime_convert: exception: ' . $e->getMessage()); - $d = new DateTime('now', $from_obj); - } - - try { - $to_obj = new DateTimeZone($to); - } catch (Exception $e) { - $to_obj = new DateTimeZone('UTC'); - } - - $d->setTimeZone($to_obj); - - return $d->format($fmt); + return Temporal::convert($s, $to, $from, $fmt); } - -/** - * @brief Wrapper for date selector, tailored for use in birthday fields. - * - * @param string $dob Date of Birth - * @return string Formatted html - */ -function dob($dob) -{ - list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); - - if ($dob < '0000-01-01') { - $value = ''; - } else { - $value = (($year > 1000) ? datetime_convert('UTC', 'UTC', $dob, 'Y-m-d') : datetime_convert('UTC', 'UTC', '1000-' . $month . '-'. $day, 'm-d')); - } - - $age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); - - $o = replace_macros(get_markup_template("field_input.tpl"), [ - '$field' => [ - 'dob', - L10n::t('Birthday:'), - $value, - (((intval($age)) > 0 ) ? L10n::t('Age: ') . $age : ""), - '', - 'placeholder="' . L10n::t('YYYY-MM-DD or MM-DD') . '"' - ] - ]); - - return $o; +function dob($dob) { + return Temporal::getDateofBirthField($dob); } -/** - * @brief Returns a date selector - * - * @param string $min - * Unix timestamp of minimum date - * @param string $max - * Unix timestap of maximum date - * @param string $default - * Unix timestamp of default date - * @param string $id - * ID and name of datetimepicker (defaults to "datetimepicker") - * - * @return string Parsed HTML output. - */ -function datesel($min, $max, $default, $id = 'datepicker') -{ - return datetimesel($min, $max, $default, '', $id, true, false, '', ''); +function datesel($min, $max, $default, $id = 'datepicker') { + return Temporal::getDateField($min, $max, $default, $id); } -/** - * @brief Returns a time selector - * - * @param $h - * Already selected hour - * @param $m - * Already selected minute - * @param string $id - * ID and name of datetimepicker (defaults to "timepicker") - * - * @return string Parsed HTML output. - */ -function timesel($h, $m, $id = 'timepicker') -{ - return datetimesel(new DateTime(), new DateTime(), new DateTime("$h:$m"), '', $id, false, true); +function timesel($h, $m, $id = 'timepicker') { + return Temporal::getTimeField($h, $m, $id); } -/** - * @brief Returns a datetime selector. - * - * @param string $min - * unix timestamp of minimum date - * @param string $max - * unix timestap of maximum date - * @param string $default - * unix timestamp of default date - * @param string $id - * id and name of datetimepicker (defaults to "datetimepicker") - * @param bool $pickdate - * true to show date picker (default) - * @param boolean $picktime - * true to show time picker (default) - * @param $minfrom - * set minimum date from picker with id $minfrom (none by default) - * @param $maxfrom - * set maximum date from picker with id $maxfrom (none by default) - * @param bool $required default false - * - * @return string Parsed HTML output. - * - * @todo Once browser support is better this could probably be replaced with - * native HTML5 date picker. - */ -function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) -{ - // First day of the week (0 = Sunday) - $firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0); - - $lang = substr(L10n::getBrowserLanguage(), 0, 2); - - // Check if the detected language is supported by the picker - if (!in_array($lang, ["ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu"])) { - $lang = Config::get('system', 'language', 'en'); - } - - $o = ''; - $dateformat = ''; - - if ($pickdate) { - $dateformat .= 'Y-m-d'; - } - if ($pickdate && $picktime) { - $dateformat .= ' '; - } - if ($picktime) { - $dateformat .= 'H:i'; - } - - $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; - $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; - - $input_text = $default ? date($dateformat, $default->getTimestamp()) : ''; - $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; - - $pickers = ''; - if (!$pickdate) { - $pickers .= ', datepicker: false'; - } - if (!$picktime) { - $pickers .= ',timepicker: false'; - } - - $extra_js = ''; - $pickers .= ",dayOfWeekStart: " . $firstDay . ",lang:'" . $lang . "'"; - if ($minfrom != '') { - $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; - } - if ($maxfrom != '') { - $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; - } - - $readable_format = $dateformat; - $readable_format = str_replace('Y','yyyy',$readable_format); - $readable_format = str_replace('m','mm',$readable_format); - $readable_format = str_replace('d','dd',$readable_format); - $readable_format = str_replace('H','HH',$readable_format); - $readable_format = str_replace('i','MM',$readable_format); - - $tpl = get_markup_template('field_input.tpl'); - $o .= replace_macros($tpl, [ - '$field' => [$id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'], - ]); - - $o .= ""; - - return $o; +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); } -/** - * @brief Returns a relative date string. - * - * Implements "3 seconds ago" etc. - * Based on $posted_date, (UTC). - * Results relative to current timezone. - * Limited to range of timestamps. - * - * @param string $posted_date MySQL-formatted date string (YYYY-MM-DD HH:MM:SS) - * @param string $format (optional) Parsed with sprintf() - * %1$d %2$s ago, e.g. 22 hours ago, 1 minute ago - * - * @return string with relative date - */ function relative_date($posted_date, $format = null) { - - $localtime = $posted_date . ' UTC'; - - $abs = strtotime($localtime); - - if (is_null($posted_date) || $posted_date <= NULL_DATE || $abs === false) { - return L10n::t('never'); - } - - $etime = time() - $abs; - - if ($etime < 1) { - return L10n::t('less than a second ago'); - } - - $a = [ 12 * 30 * 24 * 60 * 60 => [L10n::t('year'), L10n::t('years')], - 30 * 24 * 60 * 60 => [L10n::t('month'), L10n::t('months')], - 7 * 24 * 60 * 60 => [L10n::t('week'), L10n::t('weeks')], - 24 * 60 * 60 => [L10n::t('day'), L10n::t('days')], - 60 * 60 => [L10n::t('hour'), L10n::t('hours')], - 60 => [L10n::t('minute'), L10n::t('minutes')], - 1 => [L10n::t('second'), L10n::t('seconds')] - ]; - - foreach ($a as $secs => $str) { - $d = $etime / $secs; - if ($d >= 1) { - $r = round($d); - // translators - e.g. 22 hours ago, 1 minute ago - if (!$format) { - $format = L10n::t('%1$d %2$s ago'); - } - - return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1])); - } - } + return Temporal::getRelativeDate($posted_date, $format); } -/** - * @brief Returns timezone correct age in years. - * - * Returns the age in years, given a date of birth, the timezone of the person - * whose date of birth is provided, and the timezone of the person viewing the - * result. - * - * Why? Bear with me. Let's say I live in Mittagong, Australia, and my birthday - * is on New Year's. You live in San Bruno, California. - * When exactly are you going to see my age increase? - * - * A: 5:00 AM Dec 31 San Bruno time. That's precisely when I start celebrating - * and become a year older. If you wish me happy birthday on January 1 - * (San Bruno time), you'll be a day late. - * - * @param string $dob Date of Birth - * @param string $owner_tz (optional) Timezone of the person of interest - * @param string $viewer_tz (optional) Timezone of the person viewing - * - * @return int Age in years - */ function age($dob, $owner_tz = '', $viewer_tz = '') { - if (! intval($dob)) { - return 0; - } - if (! $owner_tz) { - $owner_tz = date_default_timezone_get(); - } - if (! $viewer_tz) { - $viewer_tz = date_default_timezone_get(); - } - - $birthdate = datetime_convert('UTC', $owner_tz,$dob . ' 00:00:00+00:00','Y-m-d'); - list($year, $month, $day) = explode("-", $birthdate); - $year_diff = datetime_convert('UTC',$viewer_tz, 'now', 'Y') - $year; - $curr_month = datetime_convert('UTC',$viewer_tz, 'now', 'm'); - $curr_day = datetime_convert('UTC',$viewer_tz, 'now', 'd'); - - if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) { - $year_diff--; - } - - return $year_diff; + return Temporal::getAgeByTimezone($dob, $owner_tz, $viewer_tz); } -/** - * @brief Get days of a month in a given year. - * - * Returns number of days in the month of the given year. - * $m = 1 is 'January' to match human usage. - * - * @param int $y Year - * @param int $m Month (1=January, 12=December) - * - * @return int Number of days in the given month - */ function get_dim($y, $m) { - - $dim = [ 0, - 31, 28, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31]; - - if ($m != 2) { - return $dim[$m]; - } elseif (((($y % 4) == 0) && (($y % 100) != 0)) || (($y % 400) == 0)) { - return 29; - } - - return $dim[2]; + return Temporal::getDaysInMonth($y, $m); } -/** - * @brief Returns the first day in month for a given month, year. - * - * Months start at 1. - * - * @param int $y Year - * @param int $m Month (1=January, 12=December) - * - * @return string day 0 = Sunday through 6 = Saturday - */ function get_first_dim($y,$m) { - $d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m)); - - return datetime_convert('UTC','UTC',$d,'w'); + return Temporal::getFirstDayInMonth($y, $m); } -/** - * @brief Output a calendar for the given month, year. - * - * If $links are provided (array), e.g. $links[12] => 'http://mylink' , - * date 12 will be linked appropriately. Today's date is also noted by - * altering td class. - * Months count from 1. - * - * @param int $y Year - * @param int $m Month - * @param array $links (default null) - * @param string $class - * - * @return string - * - * @todo Provide (prev,next) links, define class variations for different size calendars - */ function cal($y = 0, $m = 0, $links = null, $class = '') { - // month table - start at 1 to match human usage. - $mtab = [' ', - 'January', 'February', 'March', - 'April' , 'May' , 'June', - 'July' , 'August' , 'September', - 'October', 'November', 'December' - ]; - - $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y'); - $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm'); - if (!$y) { - $y = $thisyear; - } - - if (!$m) { - $m = intval($thismonth); - } - - $dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - $f = get_first_dim($y, $m); - $l = get_dim($y, $m); - $d = 1; - $dow = 0; - $started = false; - - if (($y == $thisyear) && ($m == $thismonth)) { - $tddate = intval(datetime_convert('UTC', date_default_timezone_get(), 'now', 'j')); - } - - $str_month = day_translate($mtab[$m]); - $o = ''; - $o .= ""; - for ($a = 0; $a < 7; $a ++) { - $o .= ''; - } - - $o .= ''; - - while ($d <= $l) { - if (($dow == $f) && (! $started)) { - $started = true; - } - - $today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : ''); - $o .= "'; - $dow ++; - if (($dow == 7) && ($d <= $l)) { - $dow = 0; - $o .= ''; - } - } - if ($dow) { - for ($a = $dow; $a < 7; $a ++) { - $o .= ''; - } - } - - $o .= '
$str_month $y
' . mb_substr(day_translate($dn[$a]), 0, 3, 'UTF-8') . '
"; - $day = str_replace(' ', ' ', sprintf('%2.2d', $d)); - if ($started) { - if (x($links, $d) !== false) { - $o .= "$day"; - } else { - $o .= $day; - } - - $d ++; - } else { - $o .= ' '; - } - - $o .= '
 
' . "\r\n"; - - return $o; + return Temporal::getCalendarTable($y, $m, $links, $class); } -/** - * @brief Create a birthday event. - * - * Update the year and the birthday. - */ function update_contact_birthdays() { - - // This only handles foreign or alien networks where a birthday has been provided. - // In-network birthdays are handled within local_delivery - - $r = q("SELECT * FROM `contact` WHERE `bd` != '' AND `bd` > '0001-01-01' AND SUBSTRING(`bd`, 1, 4) != `bdyear` "); - if (DBM::is_result($r)) { - foreach ($r as $rr) { - - logger('update_contact_birthday: ' . $rr['bd']); - - $nextbd = datetime_convert('UTC','UTC','now','Y') . substr($rr['bd'], 4); - - /* - * Add new birthday event for this person - * - * $bdtext is just a readable placeholder in case the event is shared - * with others. We will replace it during presentation to our $importer - * to contain a sparkle link and perhaps a photo. - */ - - // Check for duplicates - $s = q("SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1", - intval($rr['uid']), - intval($rr['id']), - dbesc(datetime_convert('UTC','UTC', $nextbd)), - dbesc('birthday')); - - if (DBM::is_result($s)) { - continue; - } - - $bdtext = L10n::t('%s\'s birthday', $rr['name']); - $bdtext2 = L10n::t('Happy Birthday %s', ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]'); - - q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", - intval($rr['uid']), - intval($rr['id']), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert('UTC','UTC', $nextbd)), - dbesc(datetime_convert('UTC','UTC', $nextbd . ' + 1 day ')), - dbesc($bdtext), - dbesc($bdtext2), - dbesc('birthday'), - intval(0) - ); - - - // update bdyear - q("UPDATE `contact` SET `bdyear` = '%s', `bd` = '%s' WHERE `uid` = %d AND `id` = %d", - dbesc(substr($nextbd,0,4)), - dbesc($nextbd), - intval($rr['uid']), - intval($rr['id']) - ); - - } - } + return Contact::updateBirthdays(); } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3ec9f5ab4..4f3a9ca73 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -12,15 +12,16 @@ use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; -use Friendica\Network\Probe; use Friendica\Model\Photo; use Friendica\Model\Profile; -use Friendica\Protocol\Diaspora; +use Friendica\Network\Probe; use Friendica\Protocol\DFRN; +use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; use Friendica\Util\Network; +use Friendica\Util\Temporal; use dba; require_once 'boot.php'; @@ -1468,4 +1469,56 @@ class Contact extends BaseObject Contact::remove($contact['id']); } } + + /** + * @brief Create a birthday event. + * + * Update the year and the birthday. + */ + public static function updateBirthdays() + { + // This only handles foreign or alien networks where a birthday has been provided. + // In-network birthdays are handled within local_delivery + + $r = q("SELECT * FROM `contact` WHERE `bd` != '' AND `bd` > '0001-01-01' AND SUBSTRING(`bd`, 1, 4) != `bdyear` "); + if (DBM::is_result($r)) { + foreach ($r as $rr) { + logger('update_contact_birthday: ' . $rr['bd']); + + $nextbd = Temporal::convert('now', 'UTC', 'UTC', 'Y') . substr($rr['bd'], 4); + + /* + * Add new birthday event for this person + * + * $bdtext is just a readable placeholder in case the event is shared + * with others. We will replace it during presentation to our $importer + * to contain a sparkle link and perhaps a photo. + */ + + // Check for duplicates + $s = q("SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1", + intval($rr['uid']), intval($rr['id']), dbesc(Temporal::convert($nextbd)), dbesc('birthday')); + + if (DBM::is_result($s)) { + continue; + } + + $bdtext = L10n::t('%s\'s birthday', $rr['name']); + $bdtext2 = L10n::t('Happy Birthday %s', ' [url=' . $rr['url'] . ']' . $rr['name'] . '[/url]'); + + q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']), + dbesc(Temporal::convert()), dbesc(Temporal::convert()), dbesc(Temporal::convert($nextbd)), + dbesc(Temporal::convert($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'), + intval(0) + ); + + + // update bdyear + q("UPDATE `contact` SET `bdyear` = '%s', `bd` = '%s' WHERE `uid` = %d AND `id` = %d", dbesc(substr($nextbd, 0, 4)), + dbesc($nextbd), intval($rr['uid']), intval($rr['id']) + ); + } + } + } } diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php new file mode 100644 index 000000000..1ec774180 --- /dev/null +++ b/src/Util/Temporal.php @@ -0,0 +1,578 @@ +'; + + usort($timezone_identifiers, [self, 'timezoneCompareCallback']); + $continent = ''; + foreach ($timezone_identifiers as $value) { + $ex = explode("/", $value); + if (count($ex) > 1) { + if ($ex[0] != $continent) { + if ($continent != '') { + $o .= ''; + } + $continent = $ex[0]; + $o .= ''; + } + if (count($ex) > 2) { + $city = substr($value, strpos($value, '/') + 1); + } else { + $city = $ex[1]; + } + } else { + $city = $ex[0]; + if ($continent != L10n::t('Miscellaneous')) { + $o .= ''; + $continent = L10n::t('Miscellaneous'); + $o .= ''; + } + } + $city = str_replace('_', ' ', L10n::t($city)); + $selected = (($value == $current) ? " selected=\"selected\" " : ""); + $o .= ""; + } + $o .= ''; + return $o; + } + + /** + * @brief Generating a Timezone selector + * + * Return a select using 'field_select_raw' template, with timezones + * grouped (primarily) by continent + * arguments follow convention as other field_* template array: + * 'name', 'label', $value, 'help' + * + * @param string $name Name of the selector + * @param string $label Label for the selector + * @param string $current Timezone + * @param string $help Help text + * + * @return string Parsed HTML + */ + public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '') + { + $options = Temporal::getTimezoneSelect($current); + $options = str_replace('', '', $options); + + $tpl = get_markup_template('field_select_raw.tpl'); + return replace_macros($tpl, [ + '$field' => [$name, $label, $current, $help, $options], + ]); + } + + /** + * @brief General purpose date parse/convert function. + * + * @param string $s Some parseable date/time string + * @param string $from Source timezone + * @param string $to Dest timezone + * @param string $fmt Output format recognised from php's DateTime class + * http://www.php.net/manual/en/datetime.format.php + * + * @return string Formatted date according to given format + */ + public static function convert($s = 'now', $to = 'UTC', $from = 'UTC', $fmt = "Y-m-d H:i:s") + { + // Defaults to UTC if nothing is set, but throws an exception if set to empty string. + // Provide some sane defaults regardless. + if ($from === '') { + $from = 'UTC'; + } + + if ($to === '') { + $to = 'UTC'; + } + + if (($s === '') || (!is_string($s))) { + $s = 'now'; + } + + /* + * Slight hackish adjustment so that 'zero' datetime actually returns what is intended + * otherwise we end up with -0001-11-30 ... + * add 32 days so that we at least get year 00, and then hack around the fact that + * months and days always start with 1. + */ + + if (substr($s, 0, 10) <= '0001-01-01') { + $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); + return str_replace('1', '0', $d->format($fmt)); + } + + try { + $from_obj = new DateTimeZone($from); + } catch (Exception $e) { + $from_obj = new DateTimeZone('UTC'); + } + + try { + $d = new DateTime($s, $from_obj); + } catch (Exception $e) { + logger('datetime_convert: exception: ' . $e->getMessage()); + $d = new DateTime('now', $from_obj); + } + + try { + $to_obj = new DateTimeZone($to); + } catch (Exception $e) { + $to_obj = new DateTimeZone('UTC'); + } + + $d->setTimeZone($to_obj); + + return $d->format($fmt); + } + + /** + * @brief Wrapper for date selector, tailored for use in birthday fields. + * + * @param string $dob Date of Birth + * @return string Formatted HTML + */ + public static function getDateofBirthField($dob) + { + list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); + + if ($dob < '0000-01-01') { + $value = ''; + } else { + $value = Temporal::convert(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'UTC', 'UTC', 'Y-m-d'); + } + + $age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); + + $tpl = get_markup_template("field_input.tpl"); + $o = replace_macros($tpl, + [ + '$field' => [ + 'dob', + L10n::t('Birthday:'), + $value, + intval($age) > 0 ? L10n::t('Age: ') . $age : "", + '', + 'placeholder="' . L10n::t('YYYY-MM-DD or MM-DD') . '"' + ] + ]); + + return $o; + } + + /** + * @brief Returns a date selector + * + * @param string $min Unix timestamp of minimum date + * @param string $max Unix timestap of maximum date + * @param string $default Unix timestamp of default date + * @param string $id ID and name of datetimepicker (defaults to "datetimepicker") + * + * @return string Parsed HTML output. + */ + public static function getDateField($min, $max, $default, $id = 'datepicker') + { + return datetimesel($min, $max, $default, '', $id, true, false, '', ''); + } + + /** + * @brief Returns a time selector + * + * @param string $h Already selected hour + * @param string $m Already selected minute + * @param string $id ID and name of datetimepicker (defaults to "timepicker") + * + * @return string Parsed HTML output. + */ + public static function getTimeField($h, $m, $id = 'timepicker') + { + return datetimesel(new DateTime(), new DateTime(), new DateTime("$h:$m"), '', $id, false, true); + } + + /** + * @brief Returns a datetime selector. + * + * @param string $min Unix timestamp of minimum date + * @param string $max Unix timestamp of maximum date + * @param string $default Unix timestamp of default date + * @param string $id Id and name of datetimepicker (defaults to "datetimepicker") + * @param bool $pickdate true to show date picker (default) + * @param bool $picktime true to show time picker (default) + * @param string $minfrom set minimum date from picker with id $minfrom (none by default) + * @param string $maxfrom set maximum date from picker with id $maxfrom (none by default) + * @param bool $required default false + * + * @return string Parsed HTML output. + * + * @todo Once browser support is better this could probably be replaced with + * native HTML5 date picker. + */ + public static function getDateTimeField($min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, + $picktime = true, $minfrom = '', $maxfrom = '', $required = false) + { + // First day of the week (0 = Sunday) + $firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0); + + $lang = substr(L10n::getBrowserLanguage(), 0, 2); + + // Check if the detected language is supported by the picker + if (!in_array($lang, + ["ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", + "it", "da", "no", "ja", "vi", "sl", "cs", "hu"])) { + $lang = Config::get('system', 'language', 'en'); + } + + $o = ''; + $dateformat = ''; + + if ($pickdate) { + $dateformat .= 'Y-m-d'; + } + + if ($pickdate && $picktime) { + $dateformat .= ' '; + } + + if ($picktime) { + $dateformat .= 'H:i'; + } + + $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; + $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; + + $input_text = $default ? date($dateformat, $default->getTimestamp()) : ''; + $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; + + $pickers = ''; + if (!$pickdate) { + $pickers .= ', datepicker: false'; + } + + if (!$picktime) { + $pickers .= ',timepicker: false'; + } + + $extra_js = ''; + $pickers .= ",dayOfWeekStart: " . $firstDay . ",lang:'" . $lang . "'"; + if ($minfrom != '') { + $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; + } + + if ($maxfrom != '') { + $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; + } + + $readable_format = $dateformat; + $readable_format = str_replace('Y', 'yyyy', $readable_format); + $readable_format = str_replace('m', 'mm', $readable_format); + $readable_format = str_replace('d', 'dd', $readable_format); + $readable_format = str_replace('H', 'HH', $readable_format); + $readable_format = str_replace('i', 'MM', $readable_format); + + $tpl = get_markup_template('field_input.tpl'); + $o .= replace_macros($tpl, + [ + '$field' => [ + $id, + $label, + $input_text, + '', + $required ? '*' : '', + 'placeholder="' . $readable_format . '"' + ], + ]); + + $o .= ""; + + return $o; + } + + /** + * @brief Returns a relative date string. + * + * Implements "3 seconds ago" etc. + * Based on $posted_date, (UTC). + * Results relative to current timezone. + * Limited to range of timestamps. + * + * @param string $posted_date MySQL-formatted date string (YYYY-MM-DD HH:MM:SS) + * @param string $format (optional) Parsed with sprintf() + * %1$d %2$s ago, e.g. 22 hours ago, 1 minute ago + * + * @return string with relative date + */ + public static function getRelativeDate($posted_date, $format = null) + { + $localtime = $posted_date . ' UTC'; + + $abs = strtotime($localtime); + + if (is_null($posted_date) || $posted_date <= NULL_DATE || $abs === false) { + return L10n::t('never'); + } + + $etime = time() - $abs; + + if ($etime < 1) { + return L10n::t('less than a second ago'); + } + + $a = [12 * 30 * 24 * 60 * 60 => [L10n::t('year'), L10n::t('years')], + 30 * 24 * 60 * 60 => [L10n::t('month'), L10n::t('months')], + 7 * 24 * 60 * 60 => [L10n::t('week'), L10n::t('weeks')], + 24 * 60 * 60 => [L10n::t('day'), L10n::t('days')], + 60 * 60 => [L10n::t('hour'), L10n::t('hours')], + 60 => [L10n::t('minute'), L10n::t('minutes')], + 1 => [L10n::t('second'), L10n::t('seconds')] + ]; + + foreach ($a as $secs => $str) { + $d = $etime / $secs; + if ($d >= 1) { + $r = round($d); + // translators - e.g. 22 hours ago, 1 minute ago + if (!$format) { + $format = L10n::t('%1$d %2$s ago'); + } + + return sprintf($format, $r, (($r == 1) ? $str[0] : $str[1])); + } + } + } + + /** + * @brief Returns timezone correct age in years. + * + * Returns the age in years, given a date of birth, the timezone of the person + * whose date of birth is provided, and the timezone of the person viewing the + * result. + * + * Why? Bear with me. Let's say I live in Mittagong, Australia, and my birthday + * is on New Year's. You live in San Bruno, California. + * When exactly are you going to see my age increase? + * + * A: 5:00 AM Dec 31 San Bruno time. That's precisely when I start celebrating + * and become a year older. If you wish me happy birthday on January 1 + * (San Bruno time), you'll be a day late. + * + * @param string $dob Date of Birth + * @param string $owner_tz (optional) Timezone of the person of interest + * @param string $viewer_tz (optional) Timezone of the person viewing + * + * @return int Age in years + */ + public static function getAgeByTimezone($dob, $owner_tz = '', $viewer_tz = '') + { + if (!intval($dob)) { + return 0; + } + if (!$owner_tz) { + $owner_tz = date_default_timezone_get(); + } + if (!$viewer_tz) { + $viewer_tz = date_default_timezone_get(); + } + + $birthdate = Temporal::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d'); + list($year, $month, $day) = explode("-", $birthdate); + $year_diff = Temporal::convert('now', $viewer_tz, 'UTC', 'Y') - $year; + $curr_month = Temporal::convert('now', $viewer_tz, 'UTC', 'm'); + $curr_day = Temporal::convert('now', $viewer_tz, 'UTC', 'd'); + + if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) { + $year_diff--; + } + + return $year_diff; + } + + /** + * @brief Get days of a month in a given year. + * + * Returns number of days in the month of the given year. + * $m = 1 is 'January' to match human usage. + * + * @param int $y Year + * @param int $m Month (1=January, 12=December) + * + * @return int Number of days in the given month + */ + public static function getDaysInMonth($y, $m) + { + return date('t', mktime(0, 0, 0, $m, 1, $y)); + ; + } + + /** + * @brief Returns the first day in month for a given month, year. + * + * Months start at 1. + * + * @param int $y Year + * @param int $m Month (1=January, 12=December) + * + * @return string day 0 = Sunday through 6 = Saturday + */ + public static function getFirstDayInMonth($y, $m) + { + $d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m)); + + return Temporal::convert($d, 'UTC', 'UTC', 'w'); + } + + /** + * @brief Output a calendar for the given month, year. + * + * If $links are provided (array), e.g. $links[12] => 'http://mylink' , + * date 12 will be linked appropriately. Today's date is also noted by + * altering td class. + * Months count from 1. + * + * @param int $y Year + * @param int $m Month + * @param array $links (default null) + * @param string $class + * + * @return string + * + * @todo Provide (prev, next) links, define class variations for different size calendars + */ + public static function getCalendarTable($y = 0, $m = 0, $links = null, $class = '') + { + // month table - start at 1 to match human usage. + $mtab = [' ', + 'January', 'February', 'March', + 'April', 'May', 'June', + 'July', 'August', 'September', + 'October', 'November', 'December' + ]; + + $thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); + $thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm'); + if (!$y) { + $y = $thisyear; + } + + if (!$m) { + $m = intval($thismonth); + } + + $dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + $f = get_first_dim($y, $m); + $l = get_dim($y, $m); + $d = 1; + $dow = 0; + $started = false; + + if (($y == $thisyear) && ($m == $thismonth)) { + $tddate = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'j')); + } + + $str_month = day_translate($mtab[$m]); + $o = ''; + $o .= ""; + for ($a = 0; $a < 7; $a ++) { + $o .= ''; + } + + $o .= ''; + + while ($d <= $l) { + if (($dow == $f) && (!$started)) { + $started = true; + } + + $today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : ''); + $o .= "'; + $dow ++; + if (($dow == 7) && ($d <= $l)) { + $dow = 0; + $o .= ''; + } + } + + if ($dow) { + for ($a = $dow; $a < 7; $a ++) { + $o .= ''; + } + } + + $o .= '
$str_month $y
' . mb_substr(day_translate($dn[$a]), 0, 3, 'UTF-8') . '
"; + $day = str_replace(' ', ' ', sprintf('%2.2d', $d)); + if ($started) { + if (x($links, $d) !== false) { + $o .= "$day"; + } else { + $o .= $day; + } + + $d ++; + } else { + $o .= ' '; + } + + $o .= '
 
' . "\r\n"; + + return $o; + } +} From dc366bf1f7b5b7b0fc1c1a86772783074b301993 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 24 Jan 2018 21:08:45 -0500 Subject: [PATCH 04/24] Refactor datetime_convert into Temporal::convert - Changed parameter order to save space - Refactor select_timezone into Temporal::getTimezoneSelect - Refactor field_timezone into Temporal::getTimezoneField --- boot.php | 15 ++++---- include/api.php | 22 ++++++----- include/bb2diaspora.php | 21 +++++----- include/conversation.php | 6 ++- include/datetime.php | 12 ------ include/dba.php | 7 +++- include/enotify.php | 5 ++- include/event.php | 56 +++++++++++++-------------- include/items.php | 23 +++++------ include/security.php | 7 ++-- include/text.php | 6 ++- mod/admin.php | 5 ++- mod/cal.php | 16 ++++---- mod/contacts.php | 4 +- mod/dfrn_confirm.php | 13 ++++--- mod/dfrn_request.php | 12 +++--- mod/events.php | 47 ++++++++++++----------- mod/fsuggest.php | 4 +- mod/install.php | 4 +- mod/invite.php | 4 +- mod/item.php | 17 ++++---- mod/localtime.php | 6 ++- mod/lostpass.php | 5 ++- mod/message.php | 6 ++- mod/network.php | 14 ++++--- mod/photos.php | 21 +++++----- mod/ping.php | 14 ++++--- mod/profile.php | 8 ++-- mod/profile_photo.php | 6 ++- mod/profiles.php | 10 +++-- mod/proxy.php | 3 +- mod/pubsubhubbub.php | 3 +- mod/register.php | 4 +- mod/settings.php | 5 ++- mod/videos.php | 6 ++- mod/wall_attach.php | 4 +- src/Content/OEmbed.php | 9 +++-- src/Core/Cache.php | 23 +++++------ src/Core/NotificationsManager.php | 9 +++-- src/Core/Worker.php | 18 +++++---- src/Model/Contact.php | 34 ++++++++-------- src/Model/GContact.php | 12 +++--- src/Model/Item.php | 27 ++++++------- src/Model/Mail.php | 14 ++++--- src/Model/Photo.php | 7 ++-- src/Model/Process.php | 3 +- src/Model/Profile.php | 27 ++++++------- src/Model/Queue.php | 25 ++++++------ src/Model/User.php | 10 +++-- src/Module/Login.php | 13 ++++--- src/Network/FKOAuth1.php | 3 +- src/Object/Post.php | 7 ++-- src/Protocol/DFRN.php | 51 ++++++++++++------------ src/Protocol/Diaspora.php | 64 +++++++++++++++---------------- src/Protocol/OStatus.php | 20 +++++----- src/Protocol/PortableContact.php | 35 +++++++++-------- src/Util/ParseUrl.php | 3 +- src/Worker/Cron.php | 17 ++++---- src/Worker/CronHooks.php | 3 +- src/Worker/DiscoverPoCo.php | 3 +- src/Worker/OnePoll.php | 51 ++++++++++++------------ src/Worker/UpdateGContact.php | 35 ++++++++++------- 62 files changed, 512 insertions(+), 432 deletions(-) diff --git a/boot.php b/boot.php index 732816d1b..27a5e8b3e 100644 --- a/boot.php +++ b/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); } } diff --git a/include/api.php b/include/api.php index 4edced221..727b2f028 100644 --- a/include/api.php +++ b/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()) ); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 95047d61a..47c5c9891 100644 --- a/include/bb2diaspora.php +++ b/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'])) { diff --git a/include/conversation.php b/include/conversation.php index 442ce4b8b..755f24764 100644 --- a/include/conversation.php +++ b/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' => '', diff --git a/include/datetime.php b/include/datetime.php index ff7b2a9a6..a917accc1 100644 --- a/include/datetime.php +++ b/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); } diff --git a/include/dba.php b/include/dba.php index 154217a4c..e7a5db1af 100644 --- a/include/dba.php +++ b/include/dba.php @@ -1,7 +1,10 @@ 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); diff --git a/include/enotify.php b/include/enotify.php index f07215da9..6b2f5e6ef 100644 --- a/include/enotify.php +++ b/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; diff --git a/include/event.php b/include/event.php index 48edeeae6..670936279 100644 --- a/include/event.php +++ b/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 = "

" . bbcode($ev['summary']) . "

"; @@ -59,13 +57,13 @@ function format_event_html($ev, $simple = false) { $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n"; $o .= '
' . L10n::t('Starts:') . ' '.$event_start . '
' . "\r\n"; if (! $ev['nofinish']) { $o .= '
' . L10n::t('Finishes:') . ' '.$event_end . '
' . "\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; diff --git a/include/items.php b/include/items.php index 884b91393..a5ba0718b 100644 --- a/include/items.php +++ b/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'),[ diff --git a/include/security.php b/include/security.php index 001154293..9b14ed341 100644 --- a/include/security.php +++ b/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]); } diff --git a/include/text.php b/include/text.php index 3244d7bb9..72787ae57 100644 --- a/include/text.php +++ b/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'], diff --git a/mod/admin.php b/mod/admin.php index d7495340b..9ce4f8d65 100644 --- a/mod/admin.php +++ b/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); } diff --git a/mod/cal.php b/mod/cal.php index a59643cfc..71380373e 100644 --- a/mod/cal.php +++ b/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; } diff --git a/mod/contacts.php b/mod/contacts.php index 12f6075dd..43e6ae826 100644 --- a/mod/contacts.php +++ b/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")); diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 9106f5880..95a928c37 100644 --- a/mod/dfrn_confirm.php +++ b/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), diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 41d13ff81..06b2e6b77 100644 --- a/mod/dfrn_request.php +++ b/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()) ); } diff --git a/mod/events.php b/mod/events.php index 8dec61460..703b1c0ef 100644 --- a/mod/events.php +++ b/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' ; diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 99a7f7d52..92c41661f 100644 --- a/mod/fsuggest.php +++ b/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), diff --git a/mod/install.php b/mod/install.php index c5f2e985f..1ddc8fbad 100644 --- a/mod/install.php +++ b/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(), diff --git a/mod/invite.php b/mod/invite.php index 2caba92ef..3b3b94c3d 100644 --- a/mod/invite.php +++ b/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()) { diff --git a/mod/item.php b/mod/item.php index 46a7b184c..7a5a8aab4 100644 --- a/mod/item.php +++ b/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]); diff --git a/mod/localtime.php b/mod/localtime.php index f7129656f..29402b34e 100644 --- a/mod/localtime.php +++ b/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 .= '

' . L10n::t('Please select your timezone:') . '

'; - $o .= select_timezone(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles'); + $o .= Temporal::getTimezoneSelect(($_REQUEST['timezone']) ? $_REQUEST['timezone'] : 'America/Los_Angeles'); $o .= ''; diff --git a/mod/lostpass.php b/mod/lostpass.php index c39a38cca..87e492a92 100644 --- a/mod/lostpass.php +++ b/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 diff --git a/mod/message.php b/mod/message.php index 20d024feb..c1b2d989e 100644 --- a/mod/message.php +++ b/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']), diff --git a/mod/network.php b/mod/network.php index a1100352c..b5f58be40 100644 --- a/mod/network.php +++ b/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` diff --git a/mod/photos.php b/mod/photos.php index a9e77c7c3..2a1e7a4cd 100644 --- a/mod/photos.php +++ b/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; 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'], diff --git a/mod/ping.php b/mod/ping.php index a685a924a..2bbe87254 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -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'], diff --git a/mod/profile.php b/mod/profile.php index 5c769bdfa..e5ba22d74 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -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? diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 8b4d8076d..8c3c0de89 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -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()) ); diff --git a/mod/profiles.php b/mod/profiles.php index 055bbf99e..5c4a14dd6 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -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.")], diff --git a/mod/proxy.php b/mod/proxy.php index 7efc0ffba..244a6cae2 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -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]; diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index ac85657dd..ffab754de 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -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 diff --git a/mod/register.php b/mod/register.php index 6466458a7..f0ed5cd4a 100644 --- a/mod/register.php +++ b/mod/register.php @@ -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), diff --git a/mod/settings.php b/mod/settings.php index cb052826f..3603008bf 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -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), ''], diff --git a/mod/videos.php b/mod/videos.php index ac7d0f34e..00fa88598 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -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 "
"; 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())
 				);
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index 57d7b2e95..1ad435c45 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -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,
diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php
index 170ee7ba2..4ff353fa9 100644
--- a/src/Content/OEmbed.php
+++ b/src/Content/OEmbed.php
@@ -1,4 +1,5 @@
  normalise_link($embedurl),
 						'maxwidth' => $a->videowidth,
 						'content' => $txt,
-						'created' => datetime_convert()
+						'created' => Temporal::convert()
 					], true);
 				}
 
diff --git a/src/Core/Cache.php b/src/Core/Cache.php
index 05ccdd4fe..c6368219a 100644
--- a/src/Core/Cache.php
+++ b/src/Core/Cache.php
@@ -5,9 +5,10 @@
 namespace Friendica\Core;
 
 use Friendica\Core\Config;
-use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
+use Friendica\Util\Temporal;
 use dba;
+use Memcache;
 
 require_once 'include/dba.php';
 
@@ -34,7 +35,7 @@ class Cache
 		$memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
 		$memcache_port = Config::get('system', 'memcache_port', 11211);
 
-		$memcache = new \Memcache;
+		$memcache = new Memcache;
 
 		if (!$memcache->connect($memcache_host, $memcache_port)) {
 			return false;
@@ -146,7 +147,7 @@ class Cache
 			$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
 			return;
 		}
-		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => datetime_convert()];
+		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::convert()];
 		$condition = ['k' => $key];
 		dba::update('cache', $fields, $condition, true);
 	}
@@ -164,21 +165,21 @@ class Cache
 		if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
 			if ($max_level == CACHE_MONTH) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						datetime_convert('UTC', 'UTC', "now - 30 days"),
+						Temporal::convert("now - 30 days"),
 						CACHE_MONTH];
 				dba::delete('cache', $condition);
 			}
 
 			if ($max_level <= CACHE_WEEK) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						datetime_convert('UTC', 'UTC', "now - 7 days"),
+						Temporal::convert("now - 7 days"),
 						CACHE_WEEK];
 				dba::delete('cache', $condition);
 			}
 
 			if ($max_level <= CACHE_DAY) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						datetime_convert('UTC', 'UTC', "now - 1 days"),
+						Temporal::convert("now - 1 days"),
 						CACHE_DAY];
 				dba::delete('cache', $condition);
 			}
@@ -187,7 +188,7 @@ class Cache
 
 		if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					datetime_convert('UTC', 'UTC', "now - 1 hours"),
+					Temporal::convert("now - 1 hours"),
 					CACHE_HOUR];
 			dba::delete('cache', $condition);
 
@@ -196,7 +197,7 @@ class Cache
 
 		if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					datetime_convert('UTC', 'UTC', "now - 30 minutes"),
+					Temporal::convert("now - 30 minutes"),
 					CACHE_HALF_HOUR];
 			dba::delete('cache', $condition);
 
@@ -205,7 +206,7 @@ class Cache
 
 		if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					datetime_convert('UTC', 'UTC', "now - 15 minutes"),
+					Temporal::convert("now - 15 minutes"),
 					CACHE_QUARTER_HOUR];
 			dba::delete('cache', $condition);
 
@@ -214,7 +215,7 @@ class Cache
 
 		if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					datetime_convert('UTC', 'UTC', "now - 5 minutes"),
+					Temporal::convert("now - 5 minutes"),
 					CACHE_FIVE_MINUTES];
 			dba::delete('cache', $condition);
 
@@ -223,7 +224,7 @@ class Cache
 
 		if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					datetime_convert('UTC', 'UTC', "now - 1 minutes"),
+					Temporal::convert("now - 1 minutes"),
 					CACHE_MINUTE];
 			dba::delete('cache', $condition);
 
diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php
index 7c2760a85..8853c16d5 100644
--- a/src/Core/NotificationsManager.php
+++ b/src/Core/NotificationsManager.php
@@ -14,6 +14,7 @@ use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Util\XML;
+use Friendica\Util\Temporal;
 
 require_once 'include/dba.php';
 require_once 'include/html2plain.php';
@@ -42,7 +43,7 @@ class NotificationsManager extends BaseObject
 	{
 		$rets = [];
 		foreach ($notes as $n) {
-			$local_time = datetime_convert('UTC', date_default_timezone_get(), $n['date']);
+			$local_time = Temporal::convert($n['date'], date_default_timezone_get());
 			$n['timestamp'] = strtotime($local_time);
 			$n['date_rel'] = relative_date($n['date']);
 			$n['msg_html'] = bbcode($n['msg'], false, false, false, false);
@@ -243,7 +244,7 @@ class NotificationsManager extends BaseObject
 						$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
 						$default_item_url = $it['url'];
 						$default_item_text = strip_tags(bbcode($it['msg']));
-						$default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['date'], 'r');
+						$default_item_when = Temporal::convert($it['date'], date_default_timezone_get(), 'UTC', 'r');
 						$default_item_ago = relative_date($it['date']);
 						break;
 
@@ -253,7 +254,7 @@ class NotificationsManager extends BaseObject
 						$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
 						$default_item_url = $it['author-link'];
 						$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
-						$default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
+						$default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r');
 						$default_item_ago = relative_date($it['created']);
 						break;
 
@@ -265,7 +266,7 @@ class NotificationsManager extends BaseObject
 						$default_item_text = (($it['id'] == $it['parent'])
 									? L10n::t("%s created a new post", $it['author-name'])
 									: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
-						$default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r');
+						$default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r');
 						$default_item_ago = relative_date($it['created']);
 				}
 
diff --git a/src/Core/Worker.php b/src/Core/Worker.php
index ee313bef0..cb1877dbc 100644
--- a/src/Core/Worker.php
+++ b/src/Core/Worker.php
@@ -11,6 +11,8 @@ use Friendica\Database\DBM;
 use Friendica\Model\Process;
 use Friendica\Util\Lock;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
+
 use dba;
 
 require_once 'include/dba.php';
@@ -233,7 +235,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => datetime_convert()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -243,7 +245,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', datetime_convert());
+				Config::set('system', 'last_poller_execution', Temporal::convert());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 
@@ -276,7 +278,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => datetime_convert()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -284,7 +286,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', datetime_convert());
+				Config::set('system', 'last_poller_execution', Temporal::convert());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 		} else {
@@ -572,7 +574,7 @@ class Worker
 					}
 					dba::update(
 						'workerqueue',
-						['executed' => NULL_DATE, 'created' => datetime_convert(), 'priority' => $new_priority, 'pid' => 0],
+						['executed' => NULL_DATE, 'created' => Temporal::convert(), 'priority' => $new_priority, 'pid' => 0],
 						['id' => $entry["id"]]
 					);
 				} else {
@@ -823,7 +825,7 @@ class Worker
 		if ($found) {
 			$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
 			array_unshift($ids, $condition);
-			dba::update('workerqueue', ['executed' => datetime_convert(), 'pid' => $mypid], $ids);
+			dba::update('workerqueue', ['executed' => Temporal::convert(), 'pid' => $mypid], $ids);
 		}
 
 		return $found;
@@ -951,7 +953,7 @@ class Worker
 
 		/// @todo We should clean up the corresponding workerqueue entries as well
 		$condition = ["`created` < ? AND `command` = 'worker.php'",
-				datetime_convert('UTC', 'UTC', "now - ".$timeout." minutes")];
+				Temporal::convert("now - ".$timeout." minutes")];
 		dba::delete('process', $condition);
 	}
 
@@ -1038,7 +1040,7 @@ class Worker
 
 		$priority = PRIORITY_MEDIUM;
 		$dont_fork = Config::get("system", "worker_dont_fork");
-		$created = datetime_convert();
+		$created = Temporal::convert();
 
 		if (is_int($run_parameter)) {
 			$priority = $run_parameter;
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 4f3a9ca73..c3e154d7e 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -112,7 +112,7 @@ class Contact extends BaseObject
 
 		$return = dba::insert('contact', [
 			'uid'         => $user['uid'],
-			'created'     => datetime_convert(),
+			'created'     => Temporal::convert(),
 			'self'        => 1,
 			'name'        => $user['username'],
 			'nick'        => $user['nickname'],
@@ -129,9 +129,9 @@ class Contact extends BaseObject
 			'poll'        => System::baseUrl() . '/dfrn_poll/'    . $user['nickname'],
 			'confirm'     => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
 			'poco'        => System::baseUrl() . '/poco/'         . $user['nickname'],
-			'name-date'   => datetime_convert(),
-			'uri-date'    => datetime_convert(),
-			'avatar-date' => datetime_convert(),
+			'name-date'   => Temporal::convert(),
+			'uri-date'    => Temporal::convert(),
+			'avatar-date' => Temporal::convert(),
 			'closeness'   => 0
 		]);
 
@@ -210,10 +210,10 @@ class Contact extends BaseObject
 		}
 
 		if ($contact['term-date'] <= NULL_DATE) {
-			dba::update('contact', ['term-date' => datetime_convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['term-date' => Temporal::convert()], ['id' => $contact['id']]);
 
 			if ($contact['url'] != '') {
-				dba::update('contact', ['term-date' => datetime_convert()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
+				dba::update('contact', ['term-date' => Temporal::convert()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
 			}
 		} else {
 			/* @todo
@@ -224,7 +224,7 @@ class Contact extends BaseObject
 
 			/// @todo Check for contact vitality via probing
 			$expiry = $contact['term-date'] . ' + 32 days ';
-			if (datetime_convert() > datetime_convert('UTC', 'UTC', $expiry)) {
+			if (Temporal::convert() > Temporal::convert($expiry)) {
 				/* Relationship is really truly dead. archive them rather than
 				 * delete, though if the owner tries to unarchive them we'll start
 				 * the whole process over again.
@@ -688,7 +688,7 @@ class Contact extends BaseObject
 			$contact_id = $contact["id"];
 
 			// Update the contact every 7 days
-			$update_contact = ($contact['avatar-date'] < datetime_convert('', '', 'now -7 days'));
+			$update_contact = ($contact['avatar-date'] < Temporal::convert('now -7 days'));
 
 			// We force the update if the avatar is empty
 			if (!x($contact, 'avatar')) {
@@ -728,7 +728,7 @@ class Contact extends BaseObject
 		if (!$contact_id) {
 			dba::insert('contact', [
 				'uid'       => $uid,
-				'created'   => datetime_convert(),
+				'created'   => Temporal::convert(),
 				'url'       => $data["url"],
 				'nurl'      => normalise_link($data["url"]),
 				'addr'      => $data["addr"],
@@ -749,9 +749,9 @@ class Contact extends BaseObject
 				'request'   => $data["request"],
 				'confirm'   => $data["confirm"],
 				'poco'      => $data["poco"],
-				'name-date' => datetime_convert(),
-				'uri-date'  => datetime_convert(),
-				'avatar-date' => datetime_convert(),
+				'name-date' => Temporal::convert(),
+				'uri-date'  => Temporal::convert(),
+				'avatar-date' => Temporal::convert(),
 				'writable'  => 1,
 				'blocked'   => 0,
 				'readonly'  => 0,
@@ -823,13 +823,13 @@ class Contact extends BaseObject
 		}
 
 		if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) {
-			$updated['uri-date'] = datetime_convert();
+			$updated['uri-date'] = Temporal::convert();
 		}
 		if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) {
-			$updated['name-date'] = datetime_convert();
+			$updated['name-date'] = Temporal::convert();
 		}
 
-		$updated['avatar-date'] = datetime_convert();
+		$updated['avatar-date'] = Temporal::convert();
 
 		dba::update('contact', $updated, ['id' => $contact_id], $contact);
 
@@ -1026,7 +1026,7 @@ class Contact extends BaseObject
 			if ($photos) {
 				dba::update(
 					'contact',
-					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => datetime_convert()],
+					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::convert()],
 					['id' => $cid]
 				);
 
@@ -1261,7 +1261,7 @@ class Contact extends BaseObject
 			// create contact record
 			dba::insert('contact', [
 				'uid'     => $uid,
-				'created' => datetime_convert(),
+				'created' => Temporal::convert(),
 				'url'     => $ret['url'],
 				'nurl'    => normalise_link($ret['url']),
 				'addr'    => $ret['addr'],
diff --git a/src/Model/GContact.php b/src/Model/GContact.php
index 0d0969ca0..1e0adac49 100644
--- a/src/Model/GContact.php
+++ b/src/Model/GContact.php
@@ -1,4 +1,5 @@
  true, 'title' => '', 'body' => '',
-					'edited' => datetime_convert(), 'changed' => datetime_convert()],
+					'edited' => Temporal::convert(), 'changed' => Temporal::convert()],
 				['id' => $item['id']]);
 
 		create_tags_from_item($item['id']);
@@ -300,11 +301,11 @@ class Item extends BaseObject
 		$arr['owner-name']    = trim(defaults($arr, 'owner-name', ''));
 		$arr['owner-link']    = trim(defaults($arr, 'owner-link', ''));
 		$arr['owner-avatar']  = trim(defaults($arr, 'owner-avatar', ''));
-		$arr['received']      = ((x($arr, 'received') !== false) ? datetime_convert('UTC','UTC', $arr['received']) : datetime_convert());
-		$arr['created']       = ((x($arr, 'created') !== false) ? datetime_convert('UTC','UTC', $arr['created']) : $arr['received']);
-		$arr['edited']        = ((x($arr, 'edited') !== false) ? datetime_convert('UTC','UTC', $arr['edited']) : $arr['created']);
-		$arr['changed']       = ((x($arr, 'changed') !== false) ? datetime_convert('UTC','UTC', $arr['changed']) : $arr['created']);
-		$arr['commented']     = ((x($arr, 'commented') !== false) ? datetime_convert('UTC','UTC', $arr['commented']) : $arr['created']);
+		$arr['received']      = ((x($arr, 'received') !== false) ? Temporal::convert($arr['received']) : Temporal::convert());
+		$arr['created']       = ((x($arr, 'created') !== false) ? Temporal::convert($arr['created']) : $arr['received']);
+		$arr['edited']        = ((x($arr, 'edited') !== false) ? Temporal::convert($arr['edited']) : $arr['created']);
+		$arr['changed']       = ((x($arr, 'changed') !== false) ? Temporal::convert($arr['changed']) : $arr['created']);
+		$arr['commented']     = ((x($arr, 'commented') !== false) ? Temporal::convert($arr['commented']) : $arr['created']);
 		$arr['title']         = trim(defaults($arr, 'title', ''));
 		$arr['location']      = trim(defaults($arr, 'location', ''));
 		$arr['coord']         = trim(defaults($arr, 'coord', ''));
@@ -340,13 +341,13 @@ class Item extends BaseObject
 		}
 
 		// Items cannot be stored before they happen ...
-		if ($arr['created'] > datetime_convert()) {
-			$arr['created'] = datetime_convert();
+		if ($arr['created'] > Temporal::convert()) {
+			$arr['created'] = Temporal::convert();
 		}
 
 		// We haven't invented time travel by now.
-		if ($arr['edited'] > datetime_convert()) {
-			$arr['edited'] = datetime_convert();
+		if ($arr['edited'] > Temporal::convert()) {
+			$arr['edited'] = Temporal::convert();
 		}
 
 		if (($arr['author-link'] == "") && ($arr['owner-link'] == "")) {
@@ -740,9 +741,9 @@ class Item extends BaseObject
 		// update the commented timestamp on the parent
 		// Only update "commented" if it is really a comment
 		if (($arr['verb'] == ACTIVITY_POST) || !Config::get("system", "like_no_comment")) {
-			dba::update('item', ['commented' => datetime_convert(), 'changed' => datetime_convert()], ['id' => $parent_id]);
+			dba::update('item', ['commented' => Temporal::convert(), 'changed' => Temporal::convert()], ['id' => $parent_id]);
 		} else {
-			dba::update('item', ['changed' => datetime_convert()], ['id' => $parent_id]);
+			dba::update('item', ['changed' => Temporal::convert()], ['id' => $parent_id]);
 		}
 
 		if ($dsprsig) {
@@ -1642,7 +1643,7 @@ class Item extends BaseObject
 			intval($wall ? 1 : 0)
 		);
 		if (DBM::is_result($r)) {
-			return substr(datetime_convert('',date_default_timezone_get(), $r[0]['created']),0,10);
+			return substr(Temporal::convert($r[0]['created'], date_default_timezone_get()),0,10);
 		}
 		return false;
 	}
diff --git a/src/Model/Mail.php b/src/Model/Mail.php
index be68f515f..701cf3ad9 100644
--- a/src/Model/Mail.php
+++ b/src/Model/Mail.php
@@ -1,14 +1,16 @@
  local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
-				'created' => datetime_convert(), 'updated' => datetime_convert(),
+				'created' => Temporal::convert(), 'updated' => Temporal::convert(),
 				'subject' => $subject, 'recips' => $handles];
 			if (dba::insert('conv', $fields)) {
 				$convid = dba::lastInsertId();
@@ -114,7 +116,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => datetime_convert()
+				'created' => Temporal::convert()
 			]
 		);
 
@@ -194,12 +196,12 @@ class Mail
 
 		$convid = null;
 		$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
-			'created' => datetime_convert(), 'updated' => datetime_convert(),
+			'created' => Temporal::convert(), 'updated' => Temporal::convert(),
 			'subject' => $subject, 'recips' => $handles];
 		if (dba::insert('conv', $fields)) {
 			$convid = dba::lastInsertId();
 		}
-		
+
 		if (!$convid) {
 			logger('send message: conversation not found.');
 			return -4;
@@ -222,7 +224,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => datetime_convert(),
+				'created' => Temporal::convert(),
 				'unknown' => 1
 			]
 		);
diff --git a/src/Model/Photo.php b/src/Model/Photo.php
index fc6e60a9c..a2c69f994 100644
--- a/src/Model/Photo.php
+++ b/src/Model/Photo.php
@@ -1,4 +1,5 @@
  $cid,
 			'guid' => $guid,
 			'resource-id' => $rid,
-			'created' => datetime_convert(),
-			'edited' => datetime_convert(),
+			'created' => Temporal::convert(),
+			'edited' => Temporal::convert(),
 			'filename' => basename($filename),
 			'type' => $Image->getType(),
 			'album' => $album,
diff --git a/src/Model/Process.php b/src/Model/Process.php
index 8b7ce8d34..99d5af543 100644
--- a/src/Model/Process.php
+++ b/src/Model/Process.php
@@ -5,6 +5,7 @@
 namespace Friendica\Model;
 
 use Friendica\BaseObject;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -33,7 +34,7 @@ class Process extends BaseObject
 		dba::transaction();
 
 		if (!dba::exists('process', ['pid' => $pid])) {
-			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => datetime_convert()]);
+			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::convert()]);
 		}
 
 		dba::commit();
diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index df53b5d80..665945032 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -18,6 +18,7 @@ use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Protocol\Diaspora;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -555,8 +556,8 @@ class Profile
 				WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
 				ORDER BY `start` ASC ",
 				local_user(),
-				datetime_convert('UTC', 'UTC', 'now + 6 days'),
-				datetime_convert('UTC', 'UTC', 'now')
+				Temporal::convert('now + 6 days'),
+				Temporal::convert('now')
 			);
 			if (DBM::is_result($s)) {
 				$r = dba::inArray($s);
@@ -599,7 +600,7 @@ class Profile
 
 					$rr['link'] = $url;
 					$rr['title'] = $rr['name'];
-					$rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
+					$rr['date'] = day_translate(Temporal::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
 					$rr['startime'] = null;
 					$rr['today'] = $today;
 				}
@@ -643,8 +644,8 @@ class Profile
 			WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
 			ORDER BY `start` ASC ",
 			local_user(),
-			datetime_convert('UTC', 'UTC', 'now + 7 days'),
-			datetime_convert('UTC', 'UTC', 'now - 1 days')
+			Temporal::convert('now + 7 days'),
+			Temporal::convert('now - 1 days')
 		);
 
 		$r = [];
@@ -657,8 +658,8 @@ class Profile
 					$total ++;
 				}
 
-				$strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start'], 'Y-m-d');
-				if ($strt === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
+				$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
+				if ($strt === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) {
 					$istoday = true;
 				}
 
@@ -673,17 +674,17 @@ class Profile
 					$description = L10n::t('[No description]');
 				}
 
-				$strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start']);
+				$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
 
-				if (substr($strt, 0, 10) < datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
+				if (substr($strt, 0, 10) < Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) {
 					continue;
 				}
 
-				$today = ((substr($strt, 0, 10) === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) ? true : false);
+				$today = ((substr($strt, 0, 10) === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) ? true : false);
 
 				$rr['title'] = $title;
 				$rr['description'] = $description;
-				$rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
+				$rr['date'] = day_translate(Temporal::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
 				$rr['startime'] = $strt;
 				$rr['today'] = $today;
 
@@ -729,8 +730,8 @@ class Profile
 				$short_bd_format = L10n::t('j F');
 
 				$val = intval($a->profile['dob']) ?
-					day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
-					: day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
+					day_translate(Temporal::convert($a->profile['dob'] . ' 00:00 +00:00', 'UTC', 'UTC', $year_bd_format))
+					: day_translate(Temporal::convert('2001-' . substr($a->profile['dob'], 'UTC', 'UTC', 5) . ' 00:00 +00:00', $short_bd_format));
 
 				$profile['birthday'] = [L10n::t('Birthday:'), $val];
 			}
diff --git a/src/Model/Queue.php b/src/Model/Queue.php
index 3c262ddb0..99ba6385c 100644
--- a/src/Model/Queue.php
+++ b/src/Model/Queue.php
@@ -6,6 +6,7 @@ namespace Friendica\Model;
 
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -19,9 +20,9 @@ class Queue
 	public static function updateTime($id)
 	{
 		logger('queue: requeue item ' . $id);
-		dba::update('queue', ['last' => datetime_convert()], ['id' => $id]);
+		dba::update('queue', ['last' => Temporal::convert()], ['id' => $id]);
 	}
-	
+
 	/**
 	 * @param string $id id
 	 */
@@ -30,7 +31,7 @@ class Queue
 		logger('queue: remove queue item ' . $id);
 		dba::delete('queue', ['id' => $id]);
 	}
-	
+
 	/**
 	 * @brief Checks if the communication with a given contact had problems recently
 	 *
@@ -45,9 +46,9 @@ class Queue
 			AND `last` > UTC_TIMESTAMP() - INTERVAL 15 MINUTE LIMIT 1",
 			intval($cid)
 		);
-	
+
 		$was_delayed = DBM::is_result($r);
-	
+
 		// We set "term-date" to a current date if the communication has problems.
 		// If the communication works again we reset this value.
 		if ($was_delayed) {
@@ -56,10 +57,10 @@ class Queue
 			);
 			$was_delayed = !DBM::is_result($r);
 		}
-	
+
 		return $was_delayed;
 	}
-	
+
 	/**
 	 * @param string  $cid     cid
 	 * @param string  $network network
@@ -68,17 +69,17 @@ class Queue
 	 */
 	public static function add($cid, $network, $msg, $batch = false)
 	{
-	
+
 		$max_queue = Config::get('system', 'max_contact_queue');
 		if ($max_queue < 1) {
 			$max_queue = 500;
 		}
-	
+
 		$batch_queue = Config::get('system', 'max_batch_queue');
 		if ($batch_queue < 1) {
 			$batch_queue = 1000;
 		}
-	
+
 		$r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
 			WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
 			intval($cid)
@@ -93,7 +94,7 @@ class Queue
 				return;
 			}
 		}
-	
-		dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => datetime_convert(), 'last' => datetime_convert(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
+
+		dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::convert(), 'last' => Temporal::convert(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
 	}
 }
diff --git a/src/Model/User.php b/src/Model/User.php
index c8409b584..618c5988f 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -7,8 +7,8 @@ namespace Friendica\Model;
 
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
-use Friendica\Core\PConfig;
 use Friendica\Core\L10n;
+use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
@@ -18,8 +18,10 @@ use Friendica\Model\Photo;
 use Friendica\Object\Image;
 use Friendica\Util\Crypto;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use dba;
 use Exception;
+use LightOpenID;
 
 require_once 'boot.php';
 require_once 'include/dba.php';
@@ -286,7 +288,7 @@ class User
 				$_SESSION['register'] = 1;
 				$_SESSION['openid'] = $openid_url;
 
-				$openid = new \LightOpenID;
+				$openid = new LightOpenID;
 				$openid->identity = $openid_url;
 				$openid->returnUrl = System::baseUrl() . '/openid';
 				$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
@@ -394,7 +396,7 @@ class User
 			'verified' => $verified,
 			'blocked'  => $blocked,
 			'timezone' => 'UTC',
-			'register_date' => datetime_convert(),
+			'register_date' => Temporal::convert(),
 			'default-location' => ''
 		]);
 
@@ -611,7 +613,7 @@ class User
 		dba::insert('userd', ['username' => $user['nickname']]);
 
 		// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
-		dba::update('user', ['account_removed' => true, 'account_expires_on' => datetime_convert()], ['uid' => $uid]);
+		dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::convert()], ['uid' => $uid]);
 		Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
 
 		// Send an update to the directory
diff --git a/src/Module/Login.php b/src/Module/Login.php
index ae7277329..790fc3de8 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -11,7 +11,10 @@ use Friendica\Core\L10n;
 use Friendica\Database\DBM;
 use Friendica\Model\User;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use dba;
+use Exception;
+use LightOpenID;
 
 require_once 'boot.php';
 require_once 'include/datetime.php';
@@ -68,7 +71,7 @@ class Login extends BaseModule
 
 			// Otherwise it's probably an openid.
 			try {
-				$openid = new \LightOpenID;
+				$openid = new LightOpenID;
 				$openid->identity = $openid_url;
 				$_SESSION['openid'] = $openid_url;
 				$_SESSION['remember'] = $_POST['remember'];
@@ -118,7 +121,7 @@ class Login extends BaseModule
 
 			// if we haven't failed up this point, log them in.
 			$_SESSION['remember'] = $_POST['remember'];
-			$_SESSION['last_login_date'] = datetime_convert('UTC', 'UTC');
+			$_SESSION['last_login_date'] = Temporal::convert();
 			authenticate_success($record, true, true);
 
 			if (x($_SESSION, 'return_url')) {
@@ -217,10 +220,10 @@ class Login extends BaseModule
 				// stays logged in for a long time, e.g. with "Remember Me"
 				$login_refresh = false;
 				if (!x($_SESSION['last_login_date'])) {
-					$_SESSION['last_login_date'] = datetime_convert('UTC', 'UTC');
+					$_SESSION['last_login_date'] = Temporal::convert();
 				}
-				if (strcmp(datetime_convert('UTC', 'UTC', 'now - 12 hours'), $_SESSION['last_login_date']) > 0) {
-					$_SESSION['last_login_date'] = datetime_convert('UTC', 'UTC');
+				if (strcmp(Temporal::convert('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
+					$_SESSION['last_login_date'] = Temporal::convert();
 					$login_refresh = true;
 				}
 				authenticate_success($user, false, false, $login_refresh);
diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php
index 5efa5f243..7c8f56a64 100644
--- a/src/Network/FKOAuth1.php
+++ b/src/Network/FKOAuth1.php
@@ -9,6 +9,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Network\FKOAuthDataStore;
+use Friendica\Util\Temporal;
 use dba;
 use OAuthServer;
 use OAuthSignatureMethod_HMAC_SHA1;
@@ -67,7 +68,7 @@ class FKOAuth1 extends OAuthServer
 			$_SESSION['cid'] = $a->cid;
 		}
 
-		dba::update('user', ['login_date' => datetime_convert()], ['uid' => $_SESSION['uid']]);
+		dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]);
 
 		Addon::callHooks('logged_in', $a->user);
 	}
diff --git a/src/Object/Post.php b/src/Object/Post.php
index 67ce3b7cc..4797850a4 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -13,6 +13,7 @@ use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -123,7 +124,7 @@ class Post extends BaseObject
 		if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
 			$edited = [
 				'label'    => L10n::t('This entry was edited'),
-				'date'     => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'),
+				'date'     => Temporal::convert($item['edited'], date_default_timezone_get(), 'UTC', 'r'),
 				'relative' => relative_date($item['edited'])
 			];
 		}
@@ -300,7 +301,7 @@ class Post extends BaseObject
 
 		$comment = $this->getCommentBox($indent);
 
-		if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) {
+		if (strcmp(Temporal::convert($item['created']), Temporal::convert('now - 12 hours')) > 0) {
 			$shiny = 'shiny';
 		}
 
@@ -363,7 +364,7 @@ class Post extends BaseObject
 			'osparkle'        => $osparkle,
 			'sparkle'         => $sparkle,
 			'title'           => $title_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']),
 			'app'             => $item['app'],
 			'created'         => relative_date($item['created']),
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 6a8398137..871358d98 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -27,6 +27,7 @@ use Friendica\Object\Image;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\Crypto;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use Friendica\Content\Text\BBCode;
 
@@ -228,7 +229,7 @@ class DFRN
 			}
 		}
 
-		$check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
+		$check_date = Temporal::convert($last_update);
 
 		$r = q(
 			"SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -420,7 +421,7 @@ class DFRN
 
 		XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
 		XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
-		XML::addElement($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', ATOM_TIME));
+		XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', ATOM_TIME));
 		XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
 		XML::addElement($doc, $mail, "dfrn:content", $item['body']);
 
@@ -586,7 +587,7 @@ class DFRN
 
 		/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
 
-		XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
+		XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
 
 		$author = self::addAuthor($doc, $owner, $authorelement, $public);
 		$root->appendChild($author);
@@ -621,9 +622,9 @@ class DFRN
 
 		$author = $doc->createElement($authorelement);
 
-		$namdate = datetime_convert('UTC', 'UTC', $owner['name-date'].'+00:00', ATOM_TIME);
-		$uridate = datetime_convert('UTC', 'UTC', $owner['uri-date'].'+00:00', ATOM_TIME);
-		$picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
+		$namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
+		$uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
+		$picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME);
 
 		$attributes = [];
 
@@ -902,7 +903,7 @@ class DFRN
 		}
 
 		if ($item['deleted']) {
-			$attributes = ["ref" => $item['uri'], "when" => datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', ATOM_TIME)];
+			$attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)];
 			return XML::createElement($doc, "at:deleted-entry", "", $attributes);
 		}
 
@@ -982,8 +983,8 @@ class DFRN
 		XML::addElement($doc, $entry, "id", $item["uri"]);
 		XML::addElement($doc, $entry, "title", $item["title"]);
 
-		XML::addElement($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"] . "+00:00", ATOM_TIME));
-		XML::addElement($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"] . "+00:00", ATOM_TIME));
+		XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", ATOM_TIME));
+		XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", ATOM_TIME));
 
 		// "dfrn:env" is used to read the content
 		XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
@@ -1387,7 +1388,7 @@ class DFRN
 			"SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
 			intval($contact["uid"]),
 			intval($contact["id"]),
-			dbesc(datetime_convert("UTC", "UTC", $birthday)),
+			dbesc(Temporal::convert($birthday)),
 			dbesc("birthday")
 		);
 
@@ -1405,10 +1406,10 @@ class DFRN
 			VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
 			intval($contact["uid"]),
 			intval($contact["id"]),
-			dbesc(datetime_convert()),
-			dbesc(datetime_convert()),
-			dbesc(datetime_convert("UTC", "UTC", $birthday)),
-			dbesc(datetime_convert("UTC", "UTC", $birthday . " + 1 day ")),
+			dbesc(Temporal::convert()),
+			dbesc(Temporal::convert()),
+			dbesc(Temporal::convert($birthday)),
+			dbesc(Temporal::convert($birthday . " + 1 day ")),
 			dbesc($bdtext),
 			dbesc($bdtext2),
 			dbesc("birthday")
@@ -1888,7 +1889,7 @@ class DFRN
 			intval($suggest["cid"]),
 			dbesc($suggest["body"]),
 			dbesc($hash),
-			dbesc(datetime_convert()),
+			dbesc(Temporal::convert()),
 			intval(0)
 		);
 
@@ -2080,13 +2081,13 @@ class DFRN
 
 		if (self::isEditedTimestampNewer($current, $item)) {
 			// do not accept (ignore) an earlier edit than one we currently have.
-			if (datetime_convert("UTC", "UTC", $item["edited"]) < $current["edited"]) {
+			if (Temporal::convert($item["edited"]) < $current["edited"]) {
 				return false;
 			}
 
 			$fields = ['title' => $item["title"], 'body' => $item["body"],
-					'tag' => $item["tag"], 'changed' => datetime_convert(),
-					'edited' => datetime_convert("UTC", "UTC", $item["edited"])];
+					'tag' => $item["tag"], 'changed' => Temporal::convert(),
+					'edited' => Temporal::convert($item["edited"])];
 
 			$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
 			dba::update('item', $fields, $condition);
@@ -2421,7 +2422,7 @@ class DFRN
 
 		// Is there an existing item?
 		if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
-			&& (datetime_convert("UTC", "UTC", $item["edited"]) < $current[0]["edited"])
+			&& (Temporal::convert($item["edited"]) < $current[0]["edited"])
 		) {
 			logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
 			return;
@@ -2752,9 +2753,9 @@ class DFRN
 			}
 		}
 		if ($when) {
-			$when = datetime_convert("UTC", "UTC", $when, "Y-m-d H:i:s");
+			$when = Temporal::convert($when);
 		} else {
-			$when = datetime_convert("UTC", "UTC", "now", "Y-m-d H:i:s");
+			$when = Temporal::convert("now");
 		}
 
 		if (!$uri || !$importer["id"]) {
@@ -2835,7 +2836,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(datetime_convert()),
+					dbesc(Temporal::convert()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
@@ -2848,7 +2849,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(datetime_convert()),
+					dbesc(Temporal::convert()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
@@ -3156,8 +3157,8 @@ class DFRN
 			return false;
 		}
 
-		$existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
-		$update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
+		$existing_edited = Temporal::convert($existing['edited']);
+		$update_edited = Temporal::convert($update['edited']);
 
 		return (strcmp($existing_edited, $update_edited) < 0);
 	}
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index c05db2eb1..c7f8bec02 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -76,7 +76,7 @@ class Diaspora
 				$r = q(
 					"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`)
 					VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
-					datetime_convert(),
+					Temporal::convert(),
 					dbesc($addr),
 					dbesc($addr),
 					dbesc($server),
@@ -84,9 +84,9 @@ class Diaspora
 					dbesc($batch),
 					dbesc(NETWORK_DIASPORA),
 					intval(CONTACT_IS_FOLLOWER),
-					dbesc(datetime_convert()),
-					dbesc(datetime_convert()),
-					dbesc(datetime_convert())
+					dbesc(Temporal::convert()),
+					dbesc(Temporal::convert()),
+					dbesc(Temporal::convert())
 				);
 
 				$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
@@ -870,7 +870,7 @@ class Diaspora
 				dbesc($arr["confirm"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(datetime_convert()),
+				dbesc(Temporal::convert()),
 				dbesc($arr["url"]),
 				dbesc($arr["network"])
 			);
@@ -893,7 +893,7 @@ class Diaspora
 				dbesc($arr["network"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(datetime_convert())
+				dbesc(Temporal::convert())
 			);
 		}
 
@@ -1653,9 +1653,9 @@ class Diaspora
 		$text = unxmlify($data->text);
 
 		if (isset($data->created_at)) {
-			$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
+			$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 		} else {
-			$created_at = datetime_convert();
+			$created_at = Temporal::convert();
 		}
 
 		if (isset($data->thread_parent_guid)) {
@@ -1785,7 +1785,7 @@ class Diaspora
 		$msg_guid = notags(unxmlify($mesg->guid));
 		$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
 		$msg_text = unxmlify($mesg->text);
-		$msg_created_at = datetime_convert("UTC", "UTC", notags(unxmlify($mesg->created_at)));
+		$msg_created_at = Temporal::convert(notags(unxmlify($mesg->created_at)));
 
 		if ($msg_conversation_guid != $guid) {
 			logger("message conversation guid does not belong to the current conversation.");
@@ -1830,7 +1830,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
 
 		notification(
 			[
@@ -1864,7 +1864,7 @@ class Diaspora
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
 		$subject = notags(unxmlify($data->subject));
-		$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
+		$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 		$participants = notags(unxmlify($data->participants));
 
 		$messages = $data->message;
@@ -1896,7 +1896,7 @@ class Diaspora
 				dbesc($guid),
 				dbesc($author),
 				dbesc($created_at),
-				dbesc(datetime_convert()),
+				dbesc(Temporal::convert()),
 				dbesc($subject),
 				dbesc($participants)
 			);
@@ -2097,7 +2097,7 @@ class Diaspora
 		$guid = notags(unxmlify($data->guid));
 		$conversation_guid = notags(unxmlify($data->conversation_guid));
 		$text = unxmlify($data->text);
-		$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
+		$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 
 		$contact = self::allowedContactByHandle($importer, $author, true);
 		if (!$contact) {
@@ -2163,7 +2163,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => datetime_convert()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
 		return true;
 	}
 
@@ -2314,7 +2314,7 @@ class Diaspora
 		$birthday = str_replace("1000", "1901", $birthday);
 
 		if ($birthday != "") {
-			$birthday = datetime_convert("UTC", "UTC", $birthday, "Y-m-d");
+			$birthday = Temporal::convert($birthday, "UTC", "UTC", "Y-m-d");
 		}
 
 		// this is to prevent multiple birthday notifications in a single year
@@ -2330,7 +2330,7 @@ class Diaspora
 			dbesc($name),
 			dbesc($nick),
 			dbesc($author),
-			dbesc(datetime_convert()),
+			dbesc(Temporal::convert()),
 			dbesc($birthday),
 			dbesc($location),
 			dbesc($about),
@@ -2536,7 +2536,7 @@ class Diaspora
 			intval($importer["uid"]),
 			dbesc($ret["network"]),
 			dbesc($ret["addr"]),
-			datetime_convert(),
+			Temporal::convert(),
 			dbesc($ret["url"]),
 			dbesc(normalise_link($ret["url"])),
 			dbesc($batch),
@@ -2579,7 +2579,7 @@ class Diaspora
 				0,
 				dbesc(L10n::t("Sharing notification from Diaspora network")),
 				dbesc($hash),
-				dbesc(datetime_convert())
+				dbesc(Temporal::convert())
 			);
 		} else {
 			// automatic friend approval
@@ -2610,8 +2610,8 @@ class Diaspora
 				WHERE `id` = %d
 				",
 				intval($new_relation),
-				dbesc(datetime_convert()),
-				dbesc(datetime_convert()),
+				dbesc(Temporal::convert()),
+				dbesc(Temporal::convert()),
 				intval($contact_record["id"])
 			);
 
@@ -2715,7 +2715,7 @@ class Diaspora
 	{
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
-		$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
+		$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 		$root_author = notags(unxmlify($data->root_author));
 		$root_guid = notags(unxmlify($data->root_guid));
 		/// @todo handle unprocessed property "provider_display_name"
@@ -2851,8 +2851,8 @@ class Diaspora
 					'deleted' => true,
 					'title' => '',
 					'body' => '',
-					'edited' => datetime_convert(),
-					'changed' => datetime_convert()],
+					'edited' => Temporal::convert(),
+					'changed' => Temporal::convert()],
 				['id' => $item["id"]]
 			);
 
@@ -2929,7 +2929,7 @@ class Diaspora
 	{
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
-		$created_at = datetime_convert("UTC", "UTC", notags(unxmlify($data->created_at)));
+		$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 		$public = notags(unxmlify($data->public));
 		$text = unxmlify($data->text);
 		$provider_display_name = notags(unxmlify($data->provider_display_name));
@@ -3606,10 +3606,10 @@ class Diaspora
 		}
 
 		if ($event['start']) {
-			$eventdata['start'] = datetime_convert($eventdata['timezone'], "UTC", $event['start'], $mask);
+			$eventdata['start'] = Temporal::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
 		}
 		if ($event['finish'] && !$event['nofinish']) {
-			$eventdata['end'] = datetime_convert($eventdata['timezone'], "UTC", $event['finish'], $mask);
+			$eventdata['end'] = Temporal::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
 		}
 		if ($event['summary']) {
 			$eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary']));
@@ -3651,7 +3651,7 @@ class Diaspora
 
 		$public = (($item["private"]) ? "false" : "true");
 
-		$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
+		$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
 
 		// Detect a share element and do a reshare
 		if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
@@ -3854,7 +3854,7 @@ class Diaspora
 		$parent = $p[0];
 
 		$text = html_entity_decode(bb2diaspora($item["body"]));
-		$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
+		$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
 
 		$comment = ["author" => self::myHandle($owner),
 				"guid" => $item["guid"],
@@ -4085,12 +4085,12 @@ class Diaspora
 			"author" => $cnv["creator"],
 			"guid" => $cnv["guid"],
 			"subject" => $cnv["subject"],
-			"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
+			"created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
 			"participants" => $cnv["recips"]
 		];
 
 		$body = bb2diaspora($item["body"]);
-		$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
+		$created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z');
 
 		$msg = [
 			"author" => $myaddr,
@@ -4108,7 +4108,7 @@ class Diaspora
 					"author" => $cnv["creator"],
 					"guid" => $cnv["guid"],
 					"subject" => $cnv["subject"],
-					"created_at" => datetime_convert("UTC", "UTC", $cnv['created'], 'Y-m-d\TH:i:s\Z'),
+					"created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'),
 					"participants" => $cnv["recips"],
 					"message" => $msg];
 
@@ -4216,7 +4216,7 @@ class Diaspora
 				if ($year < 1004) {
 					$year = 1004;
 				}
-				$dob = datetime_convert('UTC', 'UTC', $year . '-' . $month . '-'. $day, 'Y-m-d');
+				$dob = Temporal::convert($year . '-' . $month . '-'. $day, 'UTC', 'UTC', 'Y-m-d');
 			}
 
 			$about = $profile['about'];
diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php
index 3c0f3627b..e2bb312e7 100644
--- a/src/Protocol/OStatus.php
+++ b/src/Protocol/OStatus.php
@@ -4,7 +4,6 @@
  */
 namespace Friendica\Protocol;
 
-use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
@@ -12,13 +11,14 @@ use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
-use Friendica\Model\GContact;
 use Friendica\Model\Conversation;
+use Friendica\Model\GContact;
 use Friendica\Model\Item;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Util\Lock;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use dba;
 use DOMDocument;
@@ -199,7 +199,7 @@ class OStatus
 				$contact["location"] = $value;
 			}
 
-			$contact['name-date'] = datetime_convert();
+			$contact['name-date'] = Temporal::convert();
 
 			dba::update('contact', $contact, ['id' => $contact["id"]], $current);
 
@@ -220,7 +220,7 @@ class OStatus
 						'nurl' => normalise_link($author["author-link"]),
 						'nick' => $contact["nick"], 'alias' => $contact["alias"],
 						'about' => $contact["about"], 'location' => $contact["location"],
-						'success_update' => datetime_convert(), 'last-update' => datetime_convert()];
+						'success_update' => Temporal::convert(), 'last-update' => Temporal::convert()];
 
 				dba::update('contact', $fields, ['id' => $cid], $old_contact);
 
@@ -558,7 +558,7 @@ class OStatus
 		dba::update(
 			'item',
 			['deleted' => true, 'title' => '', 'body' => '',
-					'edited' => datetime_convert(), 'changed' => datetime_convert()],
+					'edited' => Temporal::convert(), 'changed' => Temporal::convert()],
 			['id' => $deleted["id"]]
 		);
 
@@ -1273,7 +1273,7 @@ class OStatus
 		XML::addElement($doc, $root, "title", $title);
 		XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
 		XML::addElement($doc, $root, "logo", $owner["photo"]);
-		XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
+		XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME));
 
 		$author = self::addAuthor($doc, $owner);
 		$root->appendChild($author);
@@ -1539,7 +1539,7 @@ class OStatus
 		XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
 		XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
 		XML::addElement($doc, $source, "icon", $contact["photo"]);
-		XML::addElement($doc, $source, "updated", datetime_convert("UTC", "UTC", $contact["success_update"]."+00:00", ATOM_TIME));
+		XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", ATOM_TIME));
 
 		return $source;
 	}
@@ -1923,8 +1923,8 @@ class OStatus
 
 		XML::addElement($doc, $entry, "activity:verb", $verb);
 
-		XML::addElement($doc, $entry, "published", datetime_convert("UTC", "UTC", $item["created"]."+00:00", ATOM_TIME));
-		XML::addElement($doc, $entry, "updated", datetime_convert("UTC", "UTC", $item["edited"]."+00:00", ATOM_TIME));
+		XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", ATOM_TIME));
+		XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", ATOM_TIME));
 	}
 
 	/**
@@ -2127,7 +2127,7 @@ class OStatus
 			$last_update = 'now -30 days';
 		}
 
-		$check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
+		$check_date = Temporal::convert($last_update);
 		$authorid = Contact::getIdForURL($owner["url"], 0);
 
 		$sql_extra = '';
diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php
index e70e67366..7103d3464 100644
--- a/src/Protocol/PortableContact.php
+++ b/src/Protocol/PortableContact.php
@@ -16,6 +16,7 @@ use Friendica\Model\GContact;
 use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use dba;
 use DOMDocument;
 use DOMXPath;
@@ -314,7 +315,7 @@ class PortableContact
 		$contact = ["url" => $profile];
 
 		if ($gcontacts[0]["created"] <= NULL_DATE) {
-			$contact['created'] = datetime_convert();
+			$contact['created'] = Temporal::convert();
 		}
 
 		if ($force) {
@@ -337,7 +338,7 @@ class PortableContact
 		if ($server_url != "") {
 			if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
 				if ($force) {
-					$fields = ['last_failure' => datetime_convert()];
+					$fields = ['last_failure' => Temporal::convert()];
 					dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 				}
 
@@ -411,14 +412,14 @@ class PortableContact
 
 						// Set the date of the last contact
 						/// @todo By now the function "update_gcontact" doesn't work with this field
-						//$contact["last_contact"] = datetime_convert();
+						//$contact["last_contact"] = Temporal::convert();
 
 						$contact = array_merge($contact, $noscrape);
 
 						GContact::update($contact);
 
 						if (trim($noscrape["updated"]) != "") {
-							$fields = ['last_contact' => datetime_convert()];
+							$fields = ['last_contact' => Temporal::convert()];
 							dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 							logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@@ -467,7 +468,7 @@ class PortableContact
 		}
 
 		if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
-			$fields = ['last_failure' => datetime_convert()];
+			$fields = ['last_failure' => Temporal::convert()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
@@ -483,7 +484,7 @@ class PortableContact
 		$feedret = Network::curl($data["poll"]);
 
 		if (!$feedret["success"]) {
-			$fields = ['last_failure' => datetime_convert()];
+			$fields = ['last_failure' => Temporal::convert()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
@@ -532,7 +533,7 @@ class PortableContact
 
 	public static function updateNeeded($created, $updated, $last_failure, $last_contact)
 	{
-		$now = strtotime(datetime_convert());
+		$now = strtotime(Temporal::convert());
 
 		if ($updated > $last_contact) {
 			$contact_time = strtotime($updated);
@@ -921,7 +922,7 @@ class PortableContact
 		$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
 		if (DBM::is_result($gserver)) {
 			if ($gserver["created"] <= NULL_DATE) {
-				$fields = ['created' => datetime_convert()];
+				$fields = ['created' => Temporal::convert()];
 				$condition = ['nurl' => normalise_link($server_url)];
 				dba::update('gserver', $fields, $condition);
 			}
@@ -968,7 +969,7 @@ class PortableContact
 		// Mastodon uses the "@" for user profiles.
 		// But this can be misunderstood.
 		if (parse_url($server_url, PHP_URL_USER) != '') {
-			dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -984,7 +985,7 @@ class PortableContact
 		if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
 			($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
 			logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-			dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -999,7 +1000,7 @@ class PortableContact
 			// Quit if there is a timeout
 			if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-				dba::update('gserver', ['last_failure' => datetime_convert()], ['nurl' => normalise_link($server_url)]);
+				dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
 				return false;
 			}
 
@@ -1331,9 +1332,9 @@ class PortableContact
 
 		if ($failure) {
 			$last_contact = $orig_last_contact;
-			$last_failure = datetime_convert();
+			$last_failure = Temporal::convert();
 		} else {
-			$last_contact = datetime_convert();
+			$last_contact = Temporal::convert();
 			$last_failure = $orig_last_failure;
 		}
 
@@ -1361,7 +1362,7 @@ class PortableContact
 			dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
 		} elseif (!$failure) {
 			$fields['nurl'] = normalise_link($server_url);
-			$fields['created'] = datetime_convert();
+			$fields['created'] = Temporal::convert();
 			dba::insert('gserver', $fields);
 		}
 		logger("End discovery for server " . $server_url, LOGGER_DEBUG);
@@ -1525,7 +1526,7 @@ class PortableContact
 				}
 			}
 
-			$fields = ['last_poco_query' => datetime_convert()];
+			$fields = ['last_poco_query' => Temporal::convert()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return true;
@@ -1534,7 +1535,7 @@ class PortableContact
 			self::checkServer($server["url"], $server["network"], true);
 
 			// If we couldn't reach the server, we will try it some time later
-			$fields = ['last_poco_query' => datetime_convert()];
+			$fields = ['last_poco_query' => Temporal::convert()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return false;
@@ -1560,7 +1561,7 @@ class PortableContact
 			foreach ($r as $server) {
 				if (!self::checkServer($server["url"], $server["network"])) {
 					// The server is not reachable? Okay, then we will try it later
-					$fields = ['last_poco_query' => datetime_convert()];
+					$fields = ['last_poco_query' => Temporal::convert()];
 					dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 					continue;
 				}
diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php
index 868bd7ede..23e24b123 100644
--- a/src/Util/ParseUrl.php
+++ b/src/Util/ParseUrl.php
@@ -73,7 +73,8 @@ class ParseUrl
 			[
 				'url' => normalise_link($url), 'guessing' => !$no_guessing,
 				'oembed' => $do_oembed, 'content' => serialize($data),
-				'created' => datetime_convert()],
+				'created' => Temporal::convert()
+			],
 			true
 		);
 
diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php
index 2c855d569..0b497f6f1 100644
--- a/src/Worker/Cron.php
+++ b/src/Worker/Cron.php
@@ -8,6 +8,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -70,7 +71,7 @@ Class Cron {
 
 		// once daily run birthday_updates and then expire in background
 		$d1 = Config::get('system', 'last_expire_day');
-		$d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
+		$d2 = intval(Temporal::convert('now', 'UTC', 'UTC', 'd'));
 
 		if ($d2 != intval($d1)) {
 
@@ -141,7 +142,7 @@ Class Cron {
 
 		Addon::reload();
 
-		$d = datetime_convert();
+		$d = Temporal::convert();
 
 		// Only poll from those with suitable relationships,
 		// and which have a polling address and ignore Diaspora since
@@ -217,33 +218,33 @@ Class Cron {
 				 */
 				switch ($contact['priority']) {
 					case 5:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 month")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + 1 month")) {
 							$update = true;
 						}
 						break;
 					case 4:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 week")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + 1 week")) {
 							$update = true;
 						}
 						break;
 					case 3:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
 							$update = true;
 						}
 						break;
 					case 2:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 12 hour")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + 12 hour")) {
 							$update = true;
 						}
 						break;
 					case 1:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 hour")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + 1 hour")) {
 							$update = true;
 						}
 						break;
 					case 0:
 					default:
-						if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + ".$min_poll_interval." minute")) {
+						if (Temporal::convert('now') > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
 							$update = true;
 						}
 						break;
diff --git a/src/Worker/CronHooks.php b/src/Worker/CronHooks.php
index ed1675031..7aaf2567f 100644
--- a/src/Worker/CronHooks.php
+++ b/src/Worker/CronHooks.php
@@ -8,6 +8,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Worker;
+use Friendica\Util\Temporal;
 
 Class CronHooks {
 	public static function execute($hook = '') {
@@ -44,7 +45,7 @@ Class CronHooks {
 
 		logger('cronhooks: start');
 
-		$d = datetime_convert();
+		$d = Temporal::convert();
 
 		if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
 			foreach ($a->hooks["cron"] as $hook) {
diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php
index 0657b0e1b..5bcff6d1a 100644
--- a/src/Worker/DiscoverPoCo.php
+++ b/src/Worker/DiscoverPoCo.php
@@ -12,6 +12,7 @@ use Friendica\Model\GContact;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 
 require_once 'include/datetime.php';
 
@@ -197,7 +198,7 @@ class DiscoverPoCo {
 				}
 			} else {
 				q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
-					dbesc(datetime_convert()), dbesc(normalise_link($user["url"])));
+					dbesc(Temporal::convert()), dbesc(normalise_link($user["url"])));
 			}
 
 			// Quit the loop after 3 minutes
diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php
index c83c69f7a..78fdd707e 100644
--- a/src/Worker/OnePoll.php
+++ b/src/Worker/OnePoll.php
@@ -14,6 +14,7 @@ use Friendica\Protocol\Email;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
 use Friendica\Util\XML;
+use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -43,7 +44,7 @@ class OnePoll
 			return;
 		}
 
-		$d = datetime_convert();
+		$d = Temporal::convert();
 
 		$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
 		if (!DBM::is_result($contact)) {
@@ -69,7 +70,7 @@ class OnePoll
 		// Diaspora users, archived users and followers are only checked if they still exist.
 		if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
 			$last_updated = PortableContact::lastUpdated($contact["url"], true);
-			$updated = datetime_convert();
+			$updated = Temporal::convert();
 			if ($last_updated) {
 				logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
 
@@ -98,7 +99,7 @@ class OnePoll
 			$contact['priority'] = intval($poll_interval);
 			$hub_update = false;
 
-			if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) {
+			if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
 				$hub_update = true;
 			}
 		} else {
@@ -106,8 +107,8 @@ class OnePoll
 		}
 
 		$last_update = (($contact['last-update'] <= NULL_DATE)
-			? datetime_convert('UTC', 'UTC', 'now - 7 days', ATOM_TIME)
-			: datetime_convert('UTC', 'UTC', $contact['last-update'], ATOM_TIME)
+			? Temporal::convert('now - 7 days', 'UTC', 'UTC', ATOM_TIME)
+			: Temporal::convert($contact['last-update'], 'UTC', 'UTC', ATOM_TIME)
 		);
 
 		// Update the contact entry
@@ -116,7 +117,7 @@ class OnePoll
 				logger("Skipping probably dead contact ".$contact['url']);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -125,7 +126,7 @@ class OnePoll
 				logger('Contact is marked dead');
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				return;
 			} else {
 				Contact::unmarkForArchival($contact);
@@ -136,7 +137,7 @@ class OnePoll
 			logger('Ignore public contacts');
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -148,7 +149,7 @@ class OnePoll
 			logger('No self contact for user '.$importer_uid);
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -184,7 +185,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -206,7 +207,7 @@ class OnePoll
 				Contact::markForArchival($contact);
 
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
+				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -216,7 +217,7 @@ class OnePoll
 
 				Contact::markForArchival($contact);
 
-				$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
+				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -229,7 +230,7 @@ class OnePoll
 
 				// we may not be friends anymore. Will keep trying for one month.
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
+				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
 				self::updateContact($contact, $fields);
 
 				Contact::markForArchival($contact);
@@ -240,7 +241,7 @@ class OnePoll
 
 			if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -275,7 +276,7 @@ class OnePoll
 				logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -310,7 +311,7 @@ class OnePoll
 
 			if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -320,7 +321,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -334,7 +335,7 @@ class OnePoll
 			$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
 			if ($mail_disabled) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => datetime_convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -354,7 +355,7 @@ class OnePoll
 				unset($password);
 				logger("Mail: Connect to " . $mailconf['user']);
 				if ($mbox) {
-					$fields = ['last_check' => datetime_convert()];
+					$fields = ['last_check' => Temporal::convert()];
 					dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
 					logger("Mail: Connected to " . $mailconf['user']);
 				} else {
@@ -394,7 +395,7 @@ class OnePoll
 								// Only delete when mails aren't automatically moved or deleted
 								if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
 									if ($meta->deleted && ! $item['deleted']) {
-										$fields = ['deleted' => true, 'changed' => datetime_convert()];
+										$fields = ['deleted' => true, 'changed' => Temporal::convert()];
 										dba::update('item', $fields, ['id' => $item['id']]);
 									}
 
@@ -458,7 +459,7 @@ class OnePoll
 							$datarray['title'] = notags(trim($datarray['title']));
 
 							//$datarray['title'] = notags(trim($meta->subject));
-							$datarray['created'] = datetime_convert('UTC', 'UTC', $meta->date);
+							$datarray['created'] = Temporal::convert($meta->date);
 
 							// Is it a reply?
 							$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
@@ -571,7 +572,7 @@ class OnePoll
 			if (!strstr($xml, '<')) {
 				logger('post_handshake: response from ' . $url . ' did not contain XML.');
 
-				$fields = ['last-update' => datetime_convert(), 'failure_update' => datetime_convert()];
+				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
 				self::updateContact($contact, $fields);
 				Contact::markForArchival($contact);
 				return;
@@ -615,19 +616,19 @@ class OnePoll
 				}
 			}
 
-			$updated = datetime_convert();
+			$updated = Temporal::convert();
 
 			self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
 			dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::unmarkForArchival($contact);
 		} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
-			$updated = datetime_convert();
+			$updated = Temporal::convert();
 
 			self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
 			dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::markForArchival($contact);
 		} else {
-			$updated = datetime_convert();
+			$updated = Temporal::convert();
 			dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
 		}
 
diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php
index a506f0e08..520dfed3b 100644
--- a/src/Worker/UpdateGContact.php
+++ b/src/Worker/UpdateGContact.php
@@ -1,16 +1,20 @@
 
Date: Wed, 24 Jan 2018 22:28:10 -0500
Subject: [PATCH 05/24] Add back missing use in Diaspora

---
 src/Protocol/Diaspora.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index c7f8bec02..3350cfc0f 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -27,6 +27,7 @@ use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use dba;
 use SimpleXMLElement;

From b85490515016aad50e0fe73c1174949a1f72d3c3 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Thu, 25 Jan 2018 21:33:43 -0500
Subject: [PATCH 06/24] Move ATOM_TIME to Temporal::ATOM

---
 boot.php                  |  3 +--
 include/api.php           |  6 +++---
 include/event.php         |  8 ++++----
 include/text.php          |  2 +-
 src/Protocol/DFRN.php     | 16 ++++++++--------
 src/Protocol/Diaspora.php | 12 ++++++------
 src/Protocol/OStatus.php  |  8 ++++----
 src/Util/Temporal.php     |  1 +
 src/Worker/OnePoll.php    |  4 ++--
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/boot.php b/boot.php
index 27a5e8b3e..18c76587c 100644
--- a/boot.php
+++ b/boot.php
@@ -56,7 +56,6 @@ const DB_UPDATE_FAILED = 2;      // Database check failed
  * This can be used in HTML and JavaScript where needed a line break.
  */
 define('EOL',                    "
\r\n"); -define('ATOM_TIME', 'Y-m-d\TH:i:s\Z'); /** * @brief Image storage quality. @@ -1150,7 +1149,7 @@ function feed_birthday($uid, $tz) if ($t_dob < $now) { $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; } - $birthday = Temporal::convert($bd, 'UTC', $tz, ATOM_TIME); + $birthday = Temporal::convert($bd, 'UTC', $tz, Temporal::ATOM); } } diff --git a/include/api.php b/include/api.php index 727b2f028..d24e4e297 100644 --- a/include/api.php +++ b/include/api.php @@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info) 'self' => System::baseUrl() . "/" . $a->query_string, 'base' => System::baseUrl(), 'updated' => api_date(null), - 'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', ATOM_TIME), + 'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), 'language' => $user_info['language'], 'logo' => System::baseUrl() . "/images/friendica-32.png", ]; @@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type) '@attributes' => ["type" => "integer"], 'hourly-limit' => '150', '@attributes2' => ["type" => "integer"], - 'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME), + 'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM), '@attributes3' => ["type" => "datetime"], 'reset_time_in_seconds' => strtotime('now + 1 hour'), '@attributes4' => ["type" => "integer"], @@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type) 'reset_time_in_seconds' => strtotime('now + 1 hour'), 'remaining_hits' => '150', 'hourly_limit' => '150', - 'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', ATOM_TIME)), + 'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM)), ]; } diff --git a/include/event.php b/include/event.php index 670936279..59ac8d4a2 100644 --- a/include/event.php +++ b/include/event.php @@ -57,13 +57,13 @@ function format_event_html($ev, $simple = false) { $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n"; $o .= '
' . L10n::t('Starts:') . ' '.$event_start . '
' . "\r\n"; if (! $ev['nofinish']) { $o .= '
' . L10n::t('Finishes:') . ' '.$event_end . '
' . "\r\n"; } @@ -925,7 +925,7 @@ function format_event_item($item) { // Convert the time to different formats. $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')); + $dtstart_title = Temporal::convert($item['event-start'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : 'Y-m-d\TH:i:s')); // Format: Jan till Dec. $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. @@ -937,7 +937,7 @@ function format_event_item($item) { if (!$item['event-nofinish']) { $finish = true; $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')); + $dtend_title = Temporal::convert($item['event-finish'], 'UTC', 'UTC', (($item['event-adjust']) ? Temporal::ATOM : '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. diff --git a/include/text.php b/include/text.php index 72787ae57..def479ce3 100644 --- a/include/text.php +++ b/include/text.php @@ -723,7 +723,7 @@ function logger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - Temporal::convert('now', 'UTC', 'UTC', 'Y-m-d\TH:i:s\Z'), + Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), $process_id, $LOGGER_LEVELS[$level], basename($callers[0]['file']), diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 871358d98..3145e21f2 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -421,7 +421,7 @@ class DFRN XML::addElement($doc, $mail, "dfrn:id", $item['uri']); XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']); - XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)); + XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)); XML::addElement($doc, $mail, "dfrn:subject", $item['title']); XML::addElement($doc, $mail, "dfrn:content", $item['body']); @@ -587,7 +587,7 @@ class DFRN /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP" - XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME)); + XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM)); $author = self::addAuthor($doc, $owner, $authorelement, $public); $root->appendChild($author); @@ -622,9 +622,9 @@ class DFRN $author = $doc->createElement($authorelement); - $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME); - $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME); - $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', ATOM_TIME); + $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); + $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); + $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); $attributes = []; @@ -903,7 +903,7 @@ class DFRN } if ($item['deleted']) { - $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', ATOM_TIME)]; + $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)]; return XML::createElement($doc, "at:deleted-entry", "", $attributes); } @@ -983,8 +983,8 @@ class DFRN XML::addElement($doc, $entry, "id", $item["uri"]); XML::addElement($doc, $entry, "title", $item["title"]); - XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", ATOM_TIME)); - XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", ATOM_TIME)); + XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", Temporal::ATOM)); // "dfrn:env" is used to read the content XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true)); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 3350cfc0f..db18fbb47 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3593,7 +3593,7 @@ class Diaspora $eventdata['guid'] = $event['guid']; } - $mask = 'Y-m-d\TH:i:s\Z'; + $mask = Temporal::ATOM; /// @todo - establish "all day" events in Friendica $eventdata["all_day"] = "false"; @@ -3652,7 +3652,7 @@ class Diaspora $public = (($item["private"]) ? "false" : "true"); - $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'); + $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); // Detect a share element and do a reshare if (!$item['private'] && ($ret = self::isReshare($item["body"]))) { @@ -3855,7 +3855,7 @@ class Diaspora $parent = $p[0]; $text = html_entity_decode(bb2diaspora($item["body"])); - $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'); + $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); $comment = ["author" => self::myHandle($owner), "guid" => $item["guid"], @@ -4086,12 +4086,12 @@ class Diaspora "author" => $cnv["creator"], "guid" => $cnv["guid"], "subject" => $cnv["subject"], - "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'), + "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM), "participants" => $cnv["recips"] ]; $body = bb2diaspora($item["body"]); - $created = Temporal::convert($item["created"], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'); + $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); $msg = [ "author" => $myaddr, @@ -4109,7 +4109,7 @@ class Diaspora "author" => $cnv["creator"], "guid" => $cnv["guid"], "subject" => $cnv["subject"], - "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", 'Y-m-d\TH:i:s\Z'), + "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM), "participants" => $cnv["recips"], "message" => $msg]; diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index e2bb312e7..b3c85f377 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1273,7 +1273,7 @@ class OStatus XML::addElement($doc, $root, "title", $title); XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"])); XML::addElement($doc, $root, "logo", $owner["photo"]); - XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", ATOM_TIME)); + XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM)); $author = self::addAuthor($doc, $owner); $root->appendChild($author); @@ -1539,7 +1539,7 @@ class OStatus XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]); XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]); XML::addElement($doc, $source, "icon", $contact["photo"]); - XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", ATOM_TIME)); + XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", Temporal::ATOM)); return $source; } @@ -1923,8 +1923,8 @@ class OStatus XML::addElement($doc, $entry, "activity:verb", $verb); - XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", ATOM_TIME)); - XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", ATOM_TIME)); + XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", Temporal::ATOM)); } /** diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 1ec774180..8c465b4b6 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -21,6 +21,7 @@ require_once 'include/text.php'; */ class Temporal { + const ATOM = 'Y-m-d\TH:i:s\Z'; /** * @brief Two-level sort for timezones. diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 78fdd707e..ff08ed094 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -107,8 +107,8 @@ class OnePoll } $last_update = (($contact['last-update'] <= NULL_DATE) - ? Temporal::convert('now - 7 days', 'UTC', 'UTC', ATOM_TIME) - : Temporal::convert($contact['last-update'], 'UTC', 'UTC', ATOM_TIME) + ? Temporal::convert('now - 7 days', 'UTC', 'UTC', Temporal::ATOM) + : Temporal::convert($contact['last-update'], 'UTC', 'UTC', Temporal::ATOM) ); // Update the contact entry From 38ff1b455b4e909b1bbd48f243e0a275beaa43ef Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 25 Jan 2018 22:05:05 -0500 Subject: [PATCH 07/24] Add Temporal::MYSQL constant - Rename Temporal::convert() parameter names --- include/api.php | 6 +++--- mod/poco.php | 5 +++-- mod/profile.php | 2 +- src/Protocol/PortableContact.php | 6 +++--- src/Util/Temporal.php | 22 +++++++++++----------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/api.php b/include/api.php index d24e4e297..7044524a7 100644 --- a/include/api.php +++ b/include/api.php @@ -1162,7 +1162,7 @@ function api_statuses_update($type) // Check for throttling (maximum posts per day, week and month) $throttle_day = Config::get('system', 'throttle_limit_day'); if ($throttle_day > 0) { - $datefrom = date("Y-m-d H:i:s", time() - 24*60*60); + $datefrom = date(Temporal::MYSQL, time() - 24*60*60); $r = q( "SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall` @@ -1186,7 +1186,7 @@ function api_statuses_update($type) $throttle_week = Config::get('system', 'throttle_limit_week'); if ($throttle_week > 0) { - $datefrom = date("Y-m-d H:i:s", time() - 24*60*60*7); + $datefrom = date(Temporal::MYSQL, time() - 24*60*60*7); $r = q( "SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall` @@ -1210,7 +1210,7 @@ function api_statuses_update($type) $throttle_month = Config::get('system', 'throttle_limit_month'); if ($throttle_month > 0) { - $datefrom = date("Y-m-d H:i:s", time() - 24*60*60*30); + $datefrom = date(Temporal::MYSQL, time() - 24*60*60*30); $r = q( "SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall` diff --git a/mod/poco.php b/mod/poco.php index c27cd7c49..1415ee9aa 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -9,6 +9,7 @@ use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Protocol\PortableContact; +use Friendica\Util\Temporal; function poco_init(App $a) { $system_mode = false; @@ -43,7 +44,7 @@ function poco_init(App $a) { if ($a->argc > 1 && $a->argv[1] === '@global') { // List of all profiles that this server recently had data from $global = true; - $update_limit = date("Y-m-d H:i:s", time() - 30 * 86400); + $update_limit = date(Temporal::MYSQL, time() - 30 * 86400); } if ($a->argc > 2 && $a->argv[2] === '@me') { $justme = true; @@ -80,7 +81,7 @@ function poco_init(App $a) { $sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid)); } if (x($_GET, 'updatedSince')) { - $update_limit = date("Y-m-d H:i:s", strtotime($_GET['updatedSince'])); + $update_limit = date(Temporal::MYSQL, strtotime($_GET['updatedSince'])); } if ($global) { $contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')", diff --git a/mod/profile.php b/mod/profile.php index e5ba22d74..a10c22e94 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -236,7 +236,7 @@ function profile_content(App $a, $update = 0) if ($is_owner || !$last_updated) { $sql_extra4 = " AND `item`.`unseen`"; } else { - $gmupdate = gmdate("Y-m-d H:i:s", $last_updated); + $gmupdate = gmdate(Temporal::MYSQL, $last_updated); $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'"; } diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 7103d3464..04497f16b 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -144,7 +144,7 @@ class PortableContact } if (isset($entry->updated)) { - $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); + $updated = date(Temporal::MYSQL, strtotime($entry->updated)); } if (isset($entry->network)) { @@ -1507,7 +1507,7 @@ class PortableContact $timeframe = 30; } - $updatedSince = date("Y-m-d H:i:s", time() - $timeframe * 86400); + $updatedSince = date(Temporal::MYSQL, time() - $timeframe * 86400); // Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3) $url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation"; @@ -1654,7 +1654,7 @@ class PortableContact } if (isset($entry->updated)) { - $updated = date("Y-m-d H:i:s", strtotime($entry->updated)); + $updated = date(Temporal::MYSQL, strtotime($entry->updated)); } if (isset($entry->network)) { diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 8c465b4b6..176e61647 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -22,6 +22,7 @@ require_once 'include/text.php'; class Temporal { const ATOM = 'Y-m-d\TH:i:s\Z'; + const MYSQL = 'Y-m-d H:i:s'; /** * @brief Two-level sort for timezones. @@ -123,17 +124,17 @@ class Temporal } /** - * @brief General purpose date parse/convert function. + * @brief General purpose date parse/convert/format function. * - * @param string $s Some parseable date/time string - * @param string $from Source timezone - * @param string $to Dest timezone - * @param string $fmt Output format recognised from php's DateTime class + * @param string $s Some parseable date/time string + * @param string $tz_to Destination timezone + * @param string $tz_from Source timezone + * @param string $format Output format recognised from php's DateTime class * http://www.php.net/manual/en/datetime.format.php * * @return string Formatted date according to given format */ - public static function convert($s = 'now', $to = 'UTC', $from = 'UTC', $fmt = "Y-m-d H:i:s") + public static function convert($s = 'now', $tz_to = 'UTC', $tz_from = 'UTC', $format = self::MYSQL) { // Defaults to UTC if nothing is set, but throws an exception if set to empty string. // Provide some sane defaults regardless. @@ -155,14 +156,13 @@ class Temporal * add 32 days so that we at least get year 00, and then hack around the fact that * months and days always start with 1. */ - if (substr($s, 0, 10) <= '0001-01-01') { $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC')); - return str_replace('1', '0', $d->format($fmt)); + return str_replace('1', '0', $d->format($format)); } try { - $from_obj = new DateTimeZone($from); + $from_obj = new DateTimeZone($tz_from); } catch (Exception $e) { $from_obj = new DateTimeZone('UTC'); } @@ -175,14 +175,14 @@ class Temporal } try { - $to_obj = new DateTimeZone($to); + $to_obj = new DateTimeZone($tz_to); } catch (Exception $e) { $to_obj = new DateTimeZone('UTC'); } $d->setTimeZone($to_obj); - return $d->format($fmt); + return $d->format($format); } /** From 8aff8a76eb9efc4acaab0af3c8c0ca7a011f4349 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 25 Jan 2018 23:26:51 -0500 Subject: [PATCH 08/24] Add Temporal::utcNow() --- include/api.php | 6 ++--- include/dba.php | 4 +-- include/enotify.php | 2 +- include/event.php | 4 +-- include/security.php | 4 +-- include/text.php | 4 +-- mod/admin.php | 2 +- mod/contacts.php | 2 +- mod/dfrn_confirm.php | 12 ++++----- mod/dfrn_request.php | 6 ++--- mod/fsuggest.php | 2 +- mod/invite.php | 2 +- mod/item.php | 14 +++++----- mod/lostpass.php | 2 +- mod/network.php | 6 ++--- mod/photos.php | 12 ++++----- mod/ping.php | 2 +- mod/profile_photo.php | 4 +-- mod/profiles.php | 2 +- mod/proxy.php | 2 +- mod/pubsubhubbub.php | 2 +- mod/register.php | 2 +- mod/settings.php | 2 +- mod/videos.php | 4 +-- mod/wall_attach.php | 2 +- src/Content/OEmbed.php | 2 +- src/Core/Cache.php | 2 +- src/Core/Worker.php | 14 +++++----- src/Database/DBM.php | 2 +- src/Model/Contact.php | 36 +++++++++++++------------- src/Model/GContact.php | 10 ++++---- src/Model/Item.php | 2 +- src/Model/Mail.php | 8 +++--- src/Model/Photo.php | 4 +-- src/Model/Process.php | 2 +- src/Model/Profile.php | 2 +- src/Model/Queue.php | 4 +-- src/Model/User.php | 4 +-- src/Module/Login.php | 6 ++--- src/Network/FKOAuth1.php | 2 +- src/Protocol/DFRN.php | 12 ++++----- src/Protocol/Diaspora.php | 34 ++++++++++++------------ src/Protocol/OStatus.php | 6 ++--- src/Protocol/PortableContact.php | 34 ++++++++++++------------ src/Util/ParseUrl.php | 2 +- src/Util/Temporal.php | 11 ++++++++ src/Worker/Cron.php | 16 ++++++------ src/Worker/CronHooks.php | 2 +- src/Worker/DiscoverPoCo.php | 2 +- src/Worker/OnePoll.php | 44 ++++++++++++++++---------------- src/Worker/UpdateGContact.php | 2 +- 51 files changed, 191 insertions(+), 180 deletions(-) diff --git a/include/api.php b/include/api.php index 7044524a7..d20cd03de 100644 --- a/include/api.php +++ b/include/api.php @@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info) 'self' => System::baseUrl() . "/" . $a->query_string, 'base' => System::baseUrl(), 'updated' => api_date(null), - 'atom_updated' => Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), + 'atom_updated' => Temporal::utcNow(Temporal::ATOM), 'language' => $user_info['language'], 'logo' => System::baseUrl() . "/images/friendica-32.png", ]; @@ -4216,7 +4216,7 @@ function api_fr_photo_create_update($type) $result = q( "UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'", $sql_extra, - Temporal::convert(), // update edited timestamp + Temporal::utcNow(), // update edited timestamp intval(api_user()), dbesc($photo_id), dbesc($album) @@ -4420,7 +4420,7 @@ function api_account_update_profile_image($type) q( "UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); diff --git a/include/dba.php b/include/dba.php index e7a5db1af..180748db9 100644 --- a/include/dba.php +++ b/include/dba.php @@ -190,7 +190,7 @@ class dba { if ($log) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log_index"], Temporal::convert()."\t". + @file_put_contents($a->config["system"]["db_log_index"], Temporal::utcNow()."\t". $row['key']."\t".$row['rows']."\t".$row['Extra']."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". @@ -495,7 +495,7 @@ class dba { $duration = round($duration, 3); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log"], Temporal::convert()."\t".$duration."\t". + @file_put_contents($a->config["system"]["db_log"], Temporal::utcNow()."\t".$duration."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND); diff --git a/include/enotify.php b/include/enotify.php index 6b2f5e6ef..cf219676e 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -451,7 +451,7 @@ function notification($params) $datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['url'] = $params['source_link']; $datarray['photo'] = $params['source_photo']; - $datarray['date'] = Temporal::convert(); + $datarray['date'] = Temporal::utcNow(); $datarray['uid'] = $params['uid']; $datarray['link'] = $itemlink; $datarray['iid'] = $item_id; diff --git a/include/event.php b/include/event.php index 59ac8d4a2..c69bd50e0 100644 --- a/include/event.php +++ b/include/event.php @@ -240,8 +240,8 @@ function event_store($arr) { $a = get_app(); - $arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::convert()); - $arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::convert()); + $arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::utcNow()); + $arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::utcNow()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); diff --git a/include/security.php b/include/security.php index 9b14ed341..e370e9340 100644 --- a/include/security.php +++ b/include/security.php @@ -142,10 +142,10 @@ function authenticate_success($user_record, $login_initial = false, $interactive header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"'); if ($login_initial || $login_refresh) { - dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]); + dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); // Set the login date for all identities of the user - dba::update('user', ['login_date' => Temporal::convert()], + dba::update('user', ['login_date' => Temporal::utcNow()], ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]); } diff --git a/include/text.php b/include/text.php index def479ce3..6a48d7ef8 100644 --- a/include/text.php +++ b/include/text.php @@ -723,7 +723,7 @@ function logger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - Temporal::convert('now', 'UTC', 'UTC', Temporal::ATOM), + Temporal::utcNow(Temporal::ATOM), $process_id, $LOGGER_LEVELS[$level], basename($callers[0]['file']), @@ -789,7 +789,7 @@ function dlogger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", - Temporal::convert(), + Temporal::utcNow(), $process_id, basename($callers[0]['file']), $callers[0]['line'], diff --git a/mod/admin.php b/mod/admin.php index 9ce4f8d65..9bd94cd03 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -740,7 +740,7 @@ function admin_page_summary(App $a) if (!$last_worker_call) { $showwarning = true; $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!'); - } elseif ((strtotime(Temporal::convert()) - strtotime($last_worker_call)) > 60 * 60) { + } elseif ((strtotime(Temporal::utcNow()) - strtotime($last_worker_call)) > 60 * 60) { $showwarning = true; $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call); } diff --git a/mod/contacts.php b/mod/contacts.php index 43e6ae826..6bd6f753f 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -554,7 +554,7 @@ function contacts_content(App $a) // tabs $tab_str = contacts_tab($a, $contact_id, 2); - $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('', '', 'now')) ? L10n::t('Communications lost with this contact!') : ''); + $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < Temporal::utcNow()) ? L10n::t('Communications lost with this contact!') : ''); $fetch_further_information = null; if ($contact['network'] == NETWORK_FEED) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 95a928c37..9a46d463b 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -327,8 +327,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($duplex), intval($hidden), dbesc(NETWORK_DFRN), @@ -378,8 +378,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `rel` = %d WHERE `id` = %d ", - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($addr), dbesc($notify), dbesc($poll), @@ -619,8 +619,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($duplex), intval($forum), intval($prv), diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 06b2e6b77..161cd4b1b 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -137,7 +137,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`) VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)", intval(local_user()), - Temporal::convert(), + Temporal::utcNow(), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url)), $parms['addr'], @@ -382,7 +382,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", intval($uid), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), $parms['url'], dbesc(normalise_link($url)), $parms['addr'], @@ -430,7 +430,7 @@ function dfrn_request_post(App $a) ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc($hash), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); } diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 92c41661f..ccd38217d 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -52,7 +52,7 @@ function fsuggest_post(App $a) dbesc($r[0]['request']), dbesc($r[0]['photo']), dbesc($hash), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", dbesc($hash), diff --git a/mod/invite.php b/mod/invite.php index 3b3b94c3d..8ecbbe6cd 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -62,7 +62,7 @@ function invite_post(App $a) $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", dbesc($code), - dbesc(Temporal::convert()) + dbesc(Temporal::utcNow()) ); if (! is_site_admin()) { diff --git a/mod/item.php b/mod/item.php index 7a5a8aab4..1b0010281 100644 --- a/mod/item.php +++ b/mod/item.php @@ -601,11 +601,11 @@ function item_post(App $a) { $datarray['author-link'] = $author['url']; $datarray['author-avatar'] = $author['thumb']; $datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0); - $datarray['created'] = Temporal::convert(); - $datarray['edited'] = Temporal::convert(); - $datarray['commented'] = Temporal::convert(); - $datarray['received'] = Temporal::convert(); - $datarray['changed'] = Temporal::convert(); + $datarray['created'] = Temporal::utcNow(); + $datarray['edited'] = Temporal::utcNow(); + $datarray['commented'] = Temporal::utcNow(); + $datarray['received'] = Temporal::utcNow(); + $datarray['changed'] = Temporal::utcNow(); $datarray['extid'] = $extid; $datarray['guid'] = $guid; $datarray['uri'] = $uri; @@ -709,8 +709,8 @@ function item_post(App $a) { 'file' => $datarray['file'], 'rendered-html' => $datarray['rendered-html'], 'rendered-hash' => $datarray['rendered-hash'], - 'edited' => Temporal::convert(), - 'changed' => Temporal::convert()]; + 'edited' => Temporal::utcNow(), + 'changed' => Temporal::utcNow()]; Item::update($fields, ['id' => $post_id]); diff --git a/mod/lostpass.php b/mod/lostpass.php index 87e492a92..a34562de7 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -33,7 +33,7 @@ function lostpass_post(App $a) $fields = [ 'pwdreset' => $pwdreset_token, - 'pwdreset_time' => Temporal::convert() + 'pwdreset_time' => Temporal::utcNow() ]; $result = dba::update('user', $fields, ['uid' => $user['uid']]); if ($result) { diff --git a/mod/network.php b/mod/network.php index b5f58be40..01b6413e6 100644 --- a/mod/network.php +++ b/mod/network.php @@ -790,8 +790,8 @@ function networkThreadedView(App $a, $update = 0) $top_limit = current($r)['order_date']; $bottom_limit = end($r)['order_date']; } else { - $top_limit = Temporal::convert(); - $bottom_limit = Temporal::convert(); + $top_limit = Temporal::utcNow(); + $bottom_limit = Temporal::utcNow(); } // When checking for updates we need to fetch from the newest date to the newest date before @@ -804,7 +804,7 @@ function networkThreadedView(App $a, $update = 0) $top_limit = $last_date; } elseif ($a->pager['page'] == 1) { // Highest possible top limit when we are on the first page - $top_limit = Temporal::convert(); + $top_limit = Temporal::utcNow(); } $items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item` diff --git a/mod/photos.php b/mod/photos.php index 2a1e7a4cd..a7ed50a44 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -291,7 +291,7 @@ function photos_post(App $a) if (DBM::is_result($r)) { foreach ($r as $rr) { q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), dbesc($rr['parent-uri']), intval($page_owner_uid) ); @@ -364,8 +364,8 @@ function photos_post(App $a) ); if (DBM::is_result($i)) { q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), dbesc($i[0]['uri']), intval($page_owner_uid) ); @@ -649,8 +649,8 @@ function photos_post(App $a) $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($newtag), dbesc($newinform), - dbesc(Temporal::convert()), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), + dbesc(Temporal::utcNow()), intval($item_id), intval($page_owner_uid) ); @@ -1361,7 +1361,7 @@ function photos_content(App $a) $photo = [ 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'title'=> L10n::t('View Full Size'), - 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::convert('now', 'UTC', 'UTC', 'ymdhis'), + 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::utcNow('ymdhis'), 'height' => $hires['height'], 'width' => $hires['width'], 'album' => $hires['album'], diff --git a/mod/ping.php b/mod/ping.php index 2bbe87254..9d5a6c409 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -226,7 +226,7 @@ function ping_init(App $a) ORDER BY `start` ASC ", intval(local_user()), dbesc(Temporal::convert('now + 7 days')), - dbesc(Temporal::convert('now')) + dbesc(Temporal::utcNow()) ); if (DBM::is_result($ev)) { Cache::set($cachekey, $ev, CACHE_HOUR); diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 8c3c0de89..82050e962 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -130,7 +130,7 @@ function profile_photo_post(App $a) { // so that browsers will do a cache update unconditionally $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); @@ -230,7 +230,7 @@ function profile_photo_content(App $a) { ); $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); diff --git a/mod/profiles.php b/mod/profiles.php index 5c4a14dd6..6206fdae3 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -487,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(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d", diff --git a/mod/proxy.php b/mod/proxy.php index 244a6cae2..332b5bd1b 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -188,7 +188,7 @@ function proxy_init(App $a) { die(); } - $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::convert(), 'edited' => Temporal::convert(), + $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::utcNow(), 'edited' => Temporal::utcNow(), 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime]; diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index ffab754de..4dc163cba 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -139,7 +139,7 @@ function pubsubhubbub_init(App $a) { dbesc($hub_callback)); if ($subscribe) { - $last_update = Temporal::convert(); + $last_update = Temporal::utcNow(); $push_flag = 0; // if we are just updating an old subscription, keep the diff --git a/mod/register.php b/mod/register.php index f0ed5cd4a..07a20e318 100644 --- a/mod/register.php +++ b/mod/register.php @@ -118,7 +118,7 @@ function register_post(App $a) $hash = random_string(); $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ", dbesc($hash), - dbesc(Temporal::convert()), + dbesc(Temporal::utcNow()), intval($user['uid']), dbesc($result['password']), dbesc($lang), diff --git a/mod/settings.php b/mod/settings.php index 3603008bf..5c220cb35 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -631,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(Temporal::convert()), + dbesc(Temporal::utcNow()), intval(local_user()) ); } diff --git a/mod/videos.php b/mod/videos.php index 00fa88598..66ca2979f 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -170,8 +170,8 @@ function videos_post(App $a) { //echo "
"; var_dump($i); killme();
 			if (DBM::is_result($i)) {
 				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
-					dbesc(Temporal::convert()),
-					dbesc(Temporal::convert()),
+					dbesc(Temporal::utcNow()),
+					dbesc(Temporal::utcNow()),
 					dbesc($i[0]['uri']),
 					intval(local_user())
 				);
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index 1ad435c45..8cdee398e 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -124,7 +124,7 @@ function wall_attach_post(App $a) {
 	$filedata = @file_get_contents($src);
 	$mimetype = Mimetype::getContentType($filename);
 	$hash = get_guid(64);
-	$created = Temporal::convert();
+	$created = Temporal::utcNow();
 
 	$fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
 		'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,
diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php
index 4ff353fa9..2a9db6488 100644
--- a/src/Content/OEmbed.php
+++ b/src/Content/OEmbed.php
@@ -113,7 +113,7 @@ class OEmbed
 						'url' => normalise_link($embedurl),
 						'maxwidth' => $a->videowidth,
 						'content' => $txt,
-						'created' => Temporal::convert()
+						'created' => Temporal::utcNow()
 					], true);
 				}
 
diff --git a/src/Core/Cache.php b/src/Core/Cache.php
index c6368219a..f77319a46 100644
--- a/src/Core/Cache.php
+++ b/src/Core/Cache.php
@@ -147,7 +147,7 @@ class Cache
 			$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
 			return;
 		}
-		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::convert()];
+		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::utcNow()];
 		$condition = ['k' => $key];
 		dba::update('cache', $fields, $condition, true);
 	}
diff --git a/src/Core/Worker.php b/src/Core/Worker.php
index cb1877dbc..8ff37c019 100644
--- a/src/Core/Worker.php
+++ b/src/Core/Worker.php
@@ -235,7 +235,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -245,7 +245,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', Temporal::convert());
+				Config::set('system', 'last_poller_execution', Temporal::utcNow());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 
@@ -278,7 +278,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => Temporal::convert()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -286,7 +286,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', Temporal::convert());
+				Config::set('system', 'last_poller_execution', Temporal::utcNow());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 		} else {
@@ -574,7 +574,7 @@ class Worker
 					}
 					dba::update(
 						'workerqueue',
-						['executed' => NULL_DATE, 'created' => Temporal::convert(), 'priority' => $new_priority, 'pid' => 0],
+						['executed' => NULL_DATE, 'created' => Temporal::utcNow(), 'priority' => $new_priority, 'pid' => 0],
 						['id' => $entry["id"]]
 					);
 				} else {
@@ -825,7 +825,7 @@ class Worker
 		if ($found) {
 			$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
 			array_unshift($ids, $condition);
-			dba::update('workerqueue', ['executed' => Temporal::convert(), 'pid' => $mypid], $ids);
+			dba::update('workerqueue', ['executed' => Temporal::utcNow(), 'pid' => $mypid], $ids);
 		}
 
 		return $found;
@@ -1040,7 +1040,7 @@ class Worker
 
 		$priority = PRIORITY_MEDIUM;
 		$dont_fork = Config::get("system", "worker_dont_fork");
-		$created = Temporal::convert();
+		$created = Temporal::utcNow();
 
 		if (is_int($run_parameter)) {
 			$priority = $run_parameter;
diff --git a/src/Database/DBM.php b/src/Database/DBM.php
index 8a57d04a6..ffe8785f1 100644
--- a/src/Database/DBM.php
+++ b/src/Database/DBM.php
@@ -126,6 +126,6 @@ class DBM
 			$timestamp = -62135596800;
 		}
 
-		return date('Y-m-d H:i:s', (int)$timestamp);
+		return date(Temporal::MYSQL, (int)$timestamp);
 	}
 }
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index c3e154d7e..5afeebad4 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -112,7 +112,7 @@ class Contact extends BaseObject
 
 		$return = dba::insert('contact', [
 			'uid'         => $user['uid'],
-			'created'     => Temporal::convert(),
+			'created'     => Temporal::utcNow(),
 			'self'        => 1,
 			'name'        => $user['username'],
 			'nick'        => $user['nickname'],
@@ -129,9 +129,9 @@ class Contact extends BaseObject
 			'poll'        => System::baseUrl() . '/dfrn_poll/'    . $user['nickname'],
 			'confirm'     => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
 			'poco'        => System::baseUrl() . '/poco/'         . $user['nickname'],
-			'name-date'   => Temporal::convert(),
-			'uri-date'    => Temporal::convert(),
-			'avatar-date' => Temporal::convert(),
+			'name-date'   => Temporal::utcNow(),
+			'uri-date'    => Temporal::utcNow(),
+			'avatar-date' => Temporal::utcNow(),
 			'closeness'   => 0
 		]);
 
@@ -210,10 +210,10 @@ class Contact extends BaseObject
 		}
 
 		if ($contact['term-date'] <= NULL_DATE) {
-			dba::update('contact', ['term-date' => Temporal::convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['term-date' => Temporal::utcNow()], ['id' => $contact['id']]);
 
 			if ($contact['url'] != '') {
-				dba::update('contact', ['term-date' => Temporal::convert()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
+				dba::update('contact', ['term-date' => Temporal::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
 			}
 		} else {
 			/* @todo
@@ -224,7 +224,7 @@ class Contact extends BaseObject
 
 			/// @todo Check for contact vitality via probing
 			$expiry = $contact['term-date'] . ' + 32 days ';
-			if (Temporal::convert() > Temporal::convert($expiry)) {
+			if (Temporal::utcNow() > Temporal::convert($expiry)) {
 				/* Relationship is really truly dead. archive them rather than
 				 * delete, though if the owner tries to unarchive them we'll start
 				 * the whole process over again.
@@ -728,7 +728,7 @@ class Contact extends BaseObject
 		if (!$contact_id) {
 			dba::insert('contact', [
 				'uid'       => $uid,
-				'created'   => Temporal::convert(),
+				'created'   => Temporal::utcNow(),
 				'url'       => $data["url"],
 				'nurl'      => normalise_link($data["url"]),
 				'addr'      => $data["addr"],
@@ -749,9 +749,9 @@ class Contact extends BaseObject
 				'request'   => $data["request"],
 				'confirm'   => $data["confirm"],
 				'poco'      => $data["poco"],
-				'name-date' => Temporal::convert(),
-				'uri-date'  => Temporal::convert(),
-				'avatar-date' => Temporal::convert(),
+				'name-date' => Temporal::utcNow(),
+				'uri-date'  => Temporal::utcNow(),
+				'avatar-date' => Temporal::utcNow(),
 				'writable'  => 1,
 				'blocked'   => 0,
 				'readonly'  => 0,
@@ -823,13 +823,13 @@ class Contact extends BaseObject
 		}
 
 		if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) {
-			$updated['uri-date'] = Temporal::convert();
+			$updated['uri-date'] = Temporal::utcNow();
 		}
 		if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) {
-			$updated['name-date'] = Temporal::convert();
+			$updated['name-date'] = Temporal::utcNow();
 		}
 
-		$updated['avatar-date'] = Temporal::convert();
+		$updated['avatar-date'] = Temporal::utcNow();
 
 		dba::update('contact', $updated, ['id' => $contact_id], $contact);
 
@@ -1026,7 +1026,7 @@ class Contact extends BaseObject
 			if ($photos) {
 				dba::update(
 					'contact',
-					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::convert()],
+					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::utcNow()],
 					['id' => $cid]
 				);
 
@@ -1261,7 +1261,7 @@ class Contact extends BaseObject
 			// create contact record
 			dba::insert('contact', [
 				'uid'     => $uid,
-				'created' => Temporal::convert(),
+				'created' => Temporal::utcNow(),
 				'url'     => $ret['url'],
 				'nurl'    => normalise_link($ret['url']),
 				'addr'    => $ret['addr'],
@@ -1485,7 +1485,7 @@ class Contact extends BaseObject
 			foreach ($r as $rr) {
 				logger('update_contact_birthday: ' . $rr['bd']);
 
-				$nextbd = Temporal::convert('now', 'UTC', 'UTC', 'Y') . substr($rr['bd'], 4);
+				$nextbd = Temporal::convert('Y') . substr($rr['bd'], 4);
 
 				/*
 				 * Add new birthday event for this person
@@ -1508,7 +1508,7 @@ class Contact extends BaseObject
 
 				q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`)
 				VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']),
-					dbesc(Temporal::convert()), dbesc(Temporal::convert()), dbesc(Temporal::convert($nextbd)),
+					dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::convert($nextbd)),
 					dbesc(Temporal::convert($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
 					intval(0)
 				);
diff --git a/src/Model/GContact.php b/src/Model/GContact.php
index 1e0adac49..f588ec62b 100644
--- a/src/Model/GContact.php
+++ b/src/Model/GContact.php
@@ -120,12 +120,12 @@ class GContact
 				intval($uid),
 				intval($gcid),
 				intval($zcid),
-				dbesc(Temporal::convert())
+				dbesc(Temporal::utcNow())
 			);
 		} else {
 			q(
 				"UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d",
-				dbesc(Temporal::convert()),
+				dbesc(Temporal::utcNow()),
 				intval($cid),
 				intval($uid),
 				intval($gcid),
@@ -717,8 +717,8 @@ class GContact
 				dbesc($contact["url"]),
 				dbesc(normalise_link($contact["url"])),
 				dbesc($contact["photo"]),
-				dbesc(Temporal::convert()),
-				dbesc(Temporal::convert()),
+				dbesc(Temporal::utcNow()),
+				dbesc(Temporal::utcNow()),
 				dbesc($contact["location"]),
 				dbesc($contact["about"]),
 				intval($contact["hide"]),
@@ -1050,7 +1050,7 @@ class GContact
 
 		foreach ($r as $server) {
 			self::fetchGsUsers($server["url"]);
-			q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::convert()), dbesc($server["nurl"]));
+			q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::utcNow()), dbesc($server["nurl"]));
 		}
 	}
 
diff --git a/src/Model/Item.php b/src/Model/Item.php
index 8628ac42d..62f19aeb5 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -149,7 +149,7 @@ class Item extends BaseObject
 
 		// Set the item to "deleted"
 		dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
-					'edited' => Temporal::convert(), 'changed' => Temporal::convert()],
+					'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
 				['id' => $item['id']]);
 
 		create_tags_from_item($item['id']);
diff --git a/src/Model/Mail.php b/src/Model/Mail.php
index 701cf3ad9..41981fe9e 100644
--- a/src/Model/Mail.php
+++ b/src/Model/Mail.php
@@ -82,7 +82,7 @@ class Mail
 			$handles = $recip_handle . ';' . $sender_handle;
 
 			$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
-				'created' => Temporal::convert(), 'updated' => Temporal::convert(),
+				'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
 				'subject' => $subject, 'recips' => $handles];
 			if (dba::insert('conv', $fields)) {
 				$convid = dba::lastInsertId();
@@ -116,7 +116,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => Temporal::convert()
+				'created' => Temporal::utcNow()
 			]
 		);
 
@@ -196,7 +196,7 @@ class Mail
 
 		$convid = null;
 		$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
-			'created' => Temporal::convert(), 'updated' => Temporal::convert(),
+			'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
 			'subject' => $subject, 'recips' => $handles];
 		if (dba::insert('conv', $fields)) {
 			$convid = dba::lastInsertId();
@@ -224,7 +224,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => Temporal::convert(),
+				'created' => Temporal::utcNow(),
 				'unknown' => 1
 			]
 		);
diff --git a/src/Model/Photo.php b/src/Model/Photo.php
index a2c69f994..a736c3638 100644
--- a/src/Model/Photo.php
+++ b/src/Model/Photo.php
@@ -55,8 +55,8 @@ class Photo
 			'contact-id' => $cid,
 			'guid' => $guid,
 			'resource-id' => $rid,
-			'created' => Temporal::convert(),
-			'edited' => Temporal::convert(),
+			'created' => Temporal::utcNow(),
+			'edited' => Temporal::utcNow(),
 			'filename' => basename($filename),
 			'type' => $Image->getType(),
 			'album' => $album,
diff --git a/src/Model/Process.php b/src/Model/Process.php
index 99d5af543..5cb3369c6 100644
--- a/src/Model/Process.php
+++ b/src/Model/Process.php
@@ -34,7 +34,7 @@ class Process extends BaseObject
 		dba::transaction();
 
 		if (!dba::exists('process', ['pid' => $pid])) {
-			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::convert()]);
+			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::utcNow()]);
 		}
 
 		dba::commit();
diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index 665945032..bdc64a8ac 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -557,7 +557,7 @@ class Profile
 				ORDER BY `start` ASC ",
 				local_user(),
 				Temporal::convert('now + 6 days'),
-				Temporal::convert('now')
+				Temporal::utcNow()
 			);
 			if (DBM::is_result($s)) {
 				$r = dba::inArray($s);
diff --git a/src/Model/Queue.php b/src/Model/Queue.php
index 99ba6385c..6c49ff4d1 100644
--- a/src/Model/Queue.php
+++ b/src/Model/Queue.php
@@ -20,7 +20,7 @@ class Queue
 	public static function updateTime($id)
 	{
 		logger('queue: requeue item ' . $id);
-		dba::update('queue', ['last' => Temporal::convert()], ['id' => $id]);
+		dba::update('queue', ['last' => Temporal::utcNow()], ['id' => $id]);
 	}
 
 	/**
@@ -95,6 +95,6 @@ class Queue
 			}
 		}
 
-		dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::convert(), 'last' => Temporal::convert(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
+		dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::utcNow(), 'last' => Temporal::utcNow(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
 	}
 }
diff --git a/src/Model/User.php b/src/Model/User.php
index 618c5988f..3ef2a4595 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -396,7 +396,7 @@ class User
 			'verified' => $verified,
 			'blocked'  => $blocked,
 			'timezone' => 'UTC',
-			'register_date' => Temporal::convert(),
+			'register_date' => Temporal::utcNow(),
 			'default-location' => ''
 		]);
 
@@ -613,7 +613,7 @@ class User
 		dba::insert('userd', ['username' => $user['nickname']]);
 
 		// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
-		dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::convert()], ['uid' => $uid]);
+		dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::utcNow()], ['uid' => $uid]);
 		Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
 
 		// Send an update to the directory
diff --git a/src/Module/Login.php b/src/Module/Login.php
index 790fc3de8..e922094d6 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -121,7 +121,7 @@ class Login extends BaseModule
 
 			// if we haven't failed up this point, log them in.
 			$_SESSION['remember'] = $_POST['remember'];
-			$_SESSION['last_login_date'] = Temporal::convert();
+			$_SESSION['last_login_date'] = Temporal::utcNow();
 			authenticate_success($record, true, true);
 
 			if (x($_SESSION, 'return_url')) {
@@ -220,10 +220,10 @@ class Login extends BaseModule
 				// stays logged in for a long time, e.g. with "Remember Me"
 				$login_refresh = false;
 				if (!x($_SESSION['last_login_date'])) {
-					$_SESSION['last_login_date'] = Temporal::convert();
+					$_SESSION['last_login_date'] = Temporal::utcNow();
 				}
 				if (strcmp(Temporal::convert('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
-					$_SESSION['last_login_date'] = Temporal::convert();
+					$_SESSION['last_login_date'] = Temporal::utcNow();
 					$login_refresh = true;
 				}
 				authenticate_success($user, false, false, $login_refresh);
diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php
index 7c8f56a64..f7f8f1641 100644
--- a/src/Network/FKOAuth1.php
+++ b/src/Network/FKOAuth1.php
@@ -68,7 +68,7 @@ class FKOAuth1 extends OAuthServer
 			$_SESSION['cid'] = $a->cid;
 		}
 
-		dba::update('user', ['login_date' => Temporal::convert()], ['uid' => $_SESSION['uid']]);
+		dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]);
 
 		Addon::callHooks('logged_in', $a->user);
 	}
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 3145e21f2..998a6022f 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -1406,8 +1406,8 @@ class DFRN
 			VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
 			intval($contact["uid"]),
 			intval($contact["id"]),
-			dbesc(Temporal::convert()),
-			dbesc(Temporal::convert()),
+			dbesc(Temporal::utcNow()),
+			dbesc(Temporal::utcNow()),
 			dbesc(Temporal::convert($birthday)),
 			dbesc(Temporal::convert($birthday . " + 1 day ")),
 			dbesc($bdtext),
@@ -1889,7 +1889,7 @@ class DFRN
 			intval($suggest["cid"]),
 			dbesc($suggest["body"]),
 			dbesc($hash),
-			dbesc(Temporal::convert()),
+			dbesc(Temporal::utcNow()),
 			intval(0)
 		);
 
@@ -2086,7 +2086,7 @@ class DFRN
 			}
 
 			$fields = ['title' => $item["title"], 'body' => $item["body"],
-					'tag' => $item["tag"], 'changed' => Temporal::convert(),
+					'tag' => $item["tag"], 'changed' => Temporal::utcNow(),
 					'edited' => Temporal::convert($item["edited"])];
 
 			$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
@@ -2836,7 +2836,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(Temporal::convert()),
+					dbesc(Temporal::utcNow()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
@@ -2849,7 +2849,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(Temporal::convert()),
+					dbesc(Temporal::utcNow()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index db18fbb47..afd735965 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -77,7 +77,7 @@ class Diaspora
 				$r = q(
 					"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`)
 					VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
-					Temporal::convert(),
+					Temporal::utcNow(),
 					dbesc($addr),
 					dbesc($addr),
 					dbesc($server),
@@ -85,9 +85,9 @@ class Diaspora
 					dbesc($batch),
 					dbesc(NETWORK_DIASPORA),
 					intval(CONTACT_IS_FOLLOWER),
-					dbesc(Temporal::convert()),
-					dbesc(Temporal::convert()),
-					dbesc(Temporal::convert())
+					dbesc(Temporal::utcNow()),
+					dbesc(Temporal::utcNow()),
+					dbesc(Temporal::utcNow())
 				);
 
 				$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
@@ -871,7 +871,7 @@ class Diaspora
 				dbesc($arr["confirm"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(Temporal::convert()),
+				dbesc(Temporal::utcNow()),
 				dbesc($arr["url"]),
 				dbesc($arr["network"])
 			);
@@ -894,7 +894,7 @@ class Diaspora
 				dbesc($arr["network"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(Temporal::convert())
+				dbesc(Temporal::utcNow())
 			);
 		}
 
@@ -1656,7 +1656,7 @@ class Diaspora
 		if (isset($data->created_at)) {
 			$created_at = Temporal::convert(notags(unxmlify($data->created_at)));
 		} else {
-			$created_at = Temporal::convert();
+			$created_at = Temporal::utcNow();
 		}
 
 		if (isset($data->thread_parent_guid)) {
@@ -1831,7 +1831,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
 
 		notification(
 			[
@@ -1897,7 +1897,7 @@ class Diaspora
 				dbesc($guid),
 				dbesc($author),
 				dbesc($created_at),
-				dbesc(Temporal::convert()),
+				dbesc(Temporal::utcNow()),
 				dbesc($subject),
 				dbesc($participants)
 			);
@@ -2164,7 +2164,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => Temporal::convert()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
 		return true;
 	}
 
@@ -2331,7 +2331,7 @@ class Diaspora
 			dbesc($name),
 			dbesc($nick),
 			dbesc($author),
-			dbesc(Temporal::convert()),
+			dbesc(Temporal::utcNow()),
 			dbesc($birthday),
 			dbesc($location),
 			dbesc($about),
@@ -2537,7 +2537,7 @@ class Diaspora
 			intval($importer["uid"]),
 			dbesc($ret["network"]),
 			dbesc($ret["addr"]),
-			Temporal::convert(),
+			Temporal::utcNow(),
 			dbesc($ret["url"]),
 			dbesc(normalise_link($ret["url"])),
 			dbesc($batch),
@@ -2580,7 +2580,7 @@ class Diaspora
 				0,
 				dbesc(L10n::t("Sharing notification from Diaspora network")),
 				dbesc($hash),
-				dbesc(Temporal::convert())
+				dbesc(Temporal::utcNow())
 			);
 		} else {
 			// automatic friend approval
@@ -2611,8 +2611,8 @@ class Diaspora
 				WHERE `id` = %d
 				",
 				intval($new_relation),
-				dbesc(Temporal::convert()),
-				dbesc(Temporal::convert()),
+				dbesc(Temporal::utcNow()),
+				dbesc(Temporal::utcNow()),
 				intval($contact_record["id"])
 			);
 
@@ -2852,8 +2852,8 @@ class Diaspora
 					'deleted' => true,
 					'title' => '',
 					'body' => '',
-					'edited' => Temporal::convert(),
-					'changed' => Temporal::convert()],
+					'edited' => Temporal::utcNow(),
+					'changed' => Temporal::utcNow()],
 				['id' => $item["id"]]
 			);
 
diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php
index b3c85f377..c98b8ddec 100644
--- a/src/Protocol/OStatus.php
+++ b/src/Protocol/OStatus.php
@@ -199,7 +199,7 @@ class OStatus
 				$contact["location"] = $value;
 			}
 
-			$contact['name-date'] = Temporal::convert();
+			$contact['name-date'] = Temporal::utcNow();
 
 			dba::update('contact', $contact, ['id' => $contact["id"]], $current);
 
@@ -220,7 +220,7 @@ class OStatus
 						'nurl' => normalise_link($author["author-link"]),
 						'nick' => $contact["nick"], 'alias' => $contact["alias"],
 						'about' => $contact["about"], 'location' => $contact["location"],
-						'success_update' => Temporal::convert(), 'last-update' => Temporal::convert()];
+						'success_update' => Temporal::utcNow(), 'last-update' => Temporal::utcNow()];
 
 				dba::update('contact', $fields, ['id' => $cid], $old_contact);
 
@@ -558,7 +558,7 @@ class OStatus
 		dba::update(
 			'item',
 			['deleted' => true, 'title' => '', 'body' => '',
-					'edited' => Temporal::convert(), 'changed' => Temporal::convert()],
+					'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
 			['id' => $deleted["id"]]
 		);
 
diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php
index 04497f16b..aea68eb99 100644
--- a/src/Protocol/PortableContact.php
+++ b/src/Protocol/PortableContact.php
@@ -315,7 +315,7 @@ class PortableContact
 		$contact = ["url" => $profile];
 
 		if ($gcontacts[0]["created"] <= NULL_DATE) {
-			$contact['created'] = Temporal::convert();
+			$contact['created'] = Temporal::utcNow();
 		}
 
 		if ($force) {
@@ -338,7 +338,7 @@ class PortableContact
 		if ($server_url != "") {
 			if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
 				if ($force) {
-					$fields = ['last_failure' => Temporal::convert()];
+					$fields = ['last_failure' => Temporal::utcNow()];
 					dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 				}
 
@@ -412,14 +412,14 @@ class PortableContact
 
 						// Set the date of the last contact
 						/// @todo By now the function "update_gcontact" doesn't work with this field
-						//$contact["last_contact"] = Temporal::convert();
+						//$contact["last_contact"] = Temporal::utcNow();
 
 						$contact = array_merge($contact, $noscrape);
 
 						GContact::update($contact);
 
 						if (trim($noscrape["updated"]) != "") {
-							$fields = ['last_contact' => Temporal::convert()];
+							$fields = ['last_contact' => Temporal::utcNow()];
 							dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 							logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@@ -468,7 +468,7 @@ class PortableContact
 		}
 
 		if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
-			$fields = ['last_failure' => Temporal::convert()];
+			$fields = ['last_failure' => Temporal::utcNow()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
@@ -484,7 +484,7 @@ class PortableContact
 		$feedret = Network::curl($data["poll"]);
 
 		if (!$feedret["success"]) {
-			$fields = ['last_failure' => Temporal::convert()];
+			$fields = ['last_failure' => Temporal::utcNow()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
@@ -533,7 +533,7 @@ class PortableContact
 
 	public static function updateNeeded($created, $updated, $last_failure, $last_contact)
 	{
-		$now = strtotime(Temporal::convert());
+		$now = strtotime(Temporal::utcNow());
 
 		if ($updated > $last_contact) {
 			$contact_time = strtotime($updated);
@@ -922,7 +922,7 @@ class PortableContact
 		$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
 		if (DBM::is_result($gserver)) {
 			if ($gserver["created"] <= NULL_DATE) {
-				$fields = ['created' => Temporal::convert()];
+				$fields = ['created' => Temporal::utcNow()];
 				$condition = ['nurl' => normalise_link($server_url)];
 				dba::update('gserver', $fields, $condition);
 			}
@@ -969,7 +969,7 @@ class PortableContact
 		// Mastodon uses the "@" for user profiles.
 		// But this can be misunderstood.
 		if (parse_url($server_url, PHP_URL_USER) != '') {
-			dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -985,7 +985,7 @@ class PortableContact
 		if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
 			($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
 			logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-			dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -1000,7 +1000,7 @@ class PortableContact
 			// Quit if there is a timeout
 			if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-				dba::update('gserver', ['last_failure' => Temporal::convert()], ['nurl' => normalise_link($server_url)]);
+				dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
 				return false;
 			}
 
@@ -1332,9 +1332,9 @@ class PortableContact
 
 		if ($failure) {
 			$last_contact = $orig_last_contact;
-			$last_failure = Temporal::convert();
+			$last_failure = Temporal::utcNow();
 		} else {
-			$last_contact = Temporal::convert();
+			$last_contact = Temporal::utcNow();
 			$last_failure = $orig_last_failure;
 		}
 
@@ -1362,7 +1362,7 @@ class PortableContact
 			dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
 		} elseif (!$failure) {
 			$fields['nurl'] = normalise_link($server_url);
-			$fields['created'] = Temporal::convert();
+			$fields['created'] = Temporal::utcNow();
 			dba::insert('gserver', $fields);
 		}
 		logger("End discovery for server " . $server_url, LOGGER_DEBUG);
@@ -1526,7 +1526,7 @@ class PortableContact
 				}
 			}
 
-			$fields = ['last_poco_query' => Temporal::convert()];
+			$fields = ['last_poco_query' => Temporal::utcNow()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return true;
@@ -1535,7 +1535,7 @@ class PortableContact
 			self::checkServer($server["url"], $server["network"], true);
 
 			// If we couldn't reach the server, we will try it some time later
-			$fields = ['last_poco_query' => Temporal::convert()];
+			$fields = ['last_poco_query' => Temporal::utcNow()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return false;
@@ -1561,7 +1561,7 @@ class PortableContact
 			foreach ($r as $server) {
 				if (!self::checkServer($server["url"], $server["network"])) {
 					// The server is not reachable? Okay, then we will try it later
-					$fields = ['last_poco_query' => Temporal::convert()];
+					$fields = ['last_poco_query' => Temporal::utcNow()];
 					dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 					continue;
 				}
diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php
index 23e24b123..3074e74dd 100644
--- a/src/Util/ParseUrl.php
+++ b/src/Util/ParseUrl.php
@@ -73,7 +73,7 @@ class ParseUrl
 			[
 				'url' => normalise_link($url), 'guessing' => !$no_guessing,
 				'oembed' => $do_oembed, 'content' => serialize($data),
-				'created' => Temporal::convert()
+				'created' => Temporal::utcNow()
 			],
 			true
 		);
diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php
index 176e61647..eb0bbeb8e 100644
--- a/src/Util/Temporal.php
+++ b/src/Util/Temporal.php
@@ -123,6 +123,17 @@ class Temporal
 		]);
 	}
 
+	/**
+	 * convert() shorthand for UTC now.
+	 *
+	 * @param string $format DateTime format string or Temporal constant
+	 * @return string
+	 */
+	public static function utcNow($format = self::MYSQL)
+	{
+		return self::convert('now', 'UTC', 'UTC', $format);
+	}
+
 	/**
 	 * @brief General purpose date parse/convert/format function.
 	 *
diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php
index 0b497f6f1..07ddf8bee 100644
--- a/src/Worker/Cron.php
+++ b/src/Worker/Cron.php
@@ -71,7 +71,7 @@ Class Cron {
 
 		// once daily run birthday_updates and then expire in background
 		$d1 = Config::get('system', 'last_expire_day');
-		$d2 = intval(Temporal::convert('now', 'UTC', 'UTC', 'd'));
+		$d2 = intval(Temporal::utcNow('d'));
 
 		if ($d2 != intval($d1)) {
 
@@ -142,7 +142,7 @@ Class Cron {
 
 		Addon::reload();
 
-		$d = Temporal::convert();
+		$d = Temporal::utcNow();
 
 		// Only poll from those with suitable relationships,
 		// and which have a polling address and ignore Diaspora since
@@ -218,33 +218,33 @@ Class Cron {
 				 */
 				switch ($contact['priority']) {
 					case 5:
-						if (Temporal::convert('now') > Temporal::convert($t . " + 1 month")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + 1 month")) {
 							$update = true;
 						}
 						break;
 					case 4:
-						if (Temporal::convert('now') > Temporal::convert($t . " + 1 week")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + 1 week")) {
 							$update = true;
 						}
 						break;
 					case 3:
-						if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
 							$update = true;
 						}
 						break;
 					case 2:
-						if (Temporal::convert('now') > Temporal::convert($t . " + 12 hour")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + 12 hour")) {
 							$update = true;
 						}
 						break;
 					case 1:
-						if (Temporal::convert('now') > Temporal::convert($t . " + 1 hour")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + 1 hour")) {
 							$update = true;
 						}
 						break;
 					case 0:
 					default:
-						if (Temporal::convert('now') > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
+						if (Temporal::utcNow() > Temporal::convert($t . " + ".$min_poll_interval." minute")) {
 							$update = true;
 						}
 						break;
diff --git a/src/Worker/CronHooks.php b/src/Worker/CronHooks.php
index 7aaf2567f..d8b97384e 100644
--- a/src/Worker/CronHooks.php
+++ b/src/Worker/CronHooks.php
@@ -45,7 +45,7 @@ Class CronHooks {
 
 		logger('cronhooks: start');
 
-		$d = Temporal::convert();
+		$d = Temporal::utcNow();
 
 		if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
 			foreach ($a->hooks["cron"] as $hook) {
diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php
index 5bcff6d1a..480578c8f 100644
--- a/src/Worker/DiscoverPoCo.php
+++ b/src/Worker/DiscoverPoCo.php
@@ -198,7 +198,7 @@ class DiscoverPoCo {
 				}
 			} else {
 				q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
-					dbesc(Temporal::convert()), dbesc(normalise_link($user["url"])));
+					dbesc(Temporal::utcNow()), dbesc(normalise_link($user["url"])));
 			}
 
 			// Quit the loop after 3 minutes
diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php
index ff08ed094..6e69bc3aa 100644
--- a/src/Worker/OnePoll.php
+++ b/src/Worker/OnePoll.php
@@ -44,7 +44,7 @@ class OnePoll
 			return;
 		}
 
-		$d = Temporal::convert();
+		$d = Temporal::utcNow();
 
 		$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
 		if (!DBM::is_result($contact)) {
@@ -70,7 +70,7 @@ class OnePoll
 		// Diaspora users, archived users and followers are only checked if they still exist.
 		if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
 			$last_updated = PortableContact::lastUpdated($contact["url"], true);
-			$updated = Temporal::convert();
+			$updated = Temporal::utcNow();
 			if ($last_updated) {
 				logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
 
@@ -99,7 +99,7 @@ class OnePoll
 			$contact['priority'] = intval($poll_interval);
 			$hub_update = false;
 
-			if (Temporal::convert('now') > Temporal::convert($t . " + 1 day")) {
+			if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) {
 				$hub_update = true;
 			}
 		} else {
@@ -117,7 +117,7 @@ class OnePoll
 				logger("Skipping probably dead contact ".$contact['url']);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -126,7 +126,7 @@ class OnePoll
 				logger('Contact is marked dead');
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				return;
 			} else {
 				Contact::unmarkForArchival($contact);
@@ -137,7 +137,7 @@ class OnePoll
 			logger('Ignore public contacts');
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -149,7 +149,7 @@ class OnePoll
 			logger('No self contact for user '.$importer_uid);
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -185,7 +185,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -207,7 +207,7 @@ class OnePoll
 				Contact::markForArchival($contact);
 
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
+				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -217,7 +217,7 @@ class OnePoll
 
 				Contact::markForArchival($contact);
 
-				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
+				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -230,7 +230,7 @@ class OnePoll
 
 				// we may not be friends anymore. Will keep trying for one month.
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
+				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
 				self::updateContact($contact, $fields);
 
 				Contact::markForArchival($contact);
@@ -241,7 +241,7 @@ class OnePoll
 
 			if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -276,7 +276,7 @@ class OnePoll
 				logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -311,7 +311,7 @@ class OnePoll
 
 			if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -321,7 +321,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -335,7 +335,7 @@ class OnePoll
 			$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
 			if ($mail_disabled) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::convert()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -355,7 +355,7 @@ class OnePoll
 				unset($password);
 				logger("Mail: Connect to " . $mailconf['user']);
 				if ($mbox) {
-					$fields = ['last_check' => Temporal::convert()];
+					$fields = ['last_check' => Temporal::utcNow()];
 					dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
 					logger("Mail: Connected to " . $mailconf['user']);
 				} else {
@@ -395,7 +395,7 @@ class OnePoll
 								// Only delete when mails aren't automatically moved or deleted
 								if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
 									if ($meta->deleted && ! $item['deleted']) {
-										$fields = ['deleted' => true, 'changed' => Temporal::convert()];
+										$fields = ['deleted' => true, 'changed' => Temporal::utcNow()];
 										dba::update('item', $fields, ['id' => $item['id']]);
 									}
 
@@ -572,7 +572,7 @@ class OnePoll
 			if (!strstr($xml, '<')) {
 				logger('post_handshake: response from ' . $url . ' did not contain XML.');
 
-				$fields = ['last-update' => Temporal::convert(), 'failure_update' => Temporal::convert()];
+				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
 				self::updateContact($contact, $fields);
 				Contact::markForArchival($contact);
 				return;
@@ -616,19 +616,19 @@ class OnePoll
 				}
 			}
 
-			$updated = Temporal::convert();
+			$updated = Temporal::utcNow();
 
 			self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
 			dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::unmarkForArchival($contact);
 		} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
-			$updated = Temporal::convert();
+			$updated = Temporal::utcNow();
 
 			self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
 			dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::markForArchival($contact);
 		} else {
-			$updated = Temporal::convert();
+			$updated = Temporal::utcNow();
 			dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
 		}
 
diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php
index 520dfed3b..da307b4fa 100644
--- a/src/Worker/UpdateGContact.php
+++ b/src/Worker/UpdateGContact.php
@@ -42,7 +42,7 @@ class UpdateGContact
 			}
 
 			q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
-				dbesc(Temporal::convert()), intval($contact_id));
+				dbesc(Temporal::utcNow()), intval($contact_id));
 			return;
 		}
 

From ca8209a2ceed53bfebdbd1d2f285f26081843422 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Thu, 25 Jan 2018 23:29:53 -0500
Subject: [PATCH 09/24] Add missing use in DBM

---
 src/Database/DBM.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Database/DBM.php b/src/Database/DBM.php
index ffe8785f1..463d3a325 100644
--- a/src/Database/DBM.php
+++ b/src/Database/DBM.php
@@ -5,6 +5,7 @@
 namespace Friendica\Database;
 
 use dba;
+use Friendica\Util\Temporal;
 
 require_once 'include/dba.php';
 

From 35d06bd9ebee5bad76d81a1d434090f3e255e20f Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Fri, 26 Jan 2018 07:29:32 -0500
Subject: [PATCH 10/24] Add Temporal::utc() shorthand to Temporal::convert()

---
 include/api.php           |  6 ++--
 include/bb2diaspora.php   | 12 +++----
 include/event.php         | 74 +++++++++++++++++++++++++++------------
 include/items.php         |  8 ++---
 mod/cal.php               |  6 ++--
 mod/dfrn_request.php      |  2 +-
 mod/events.php            | 10 +++---
 mod/lostpass.php          |  2 +-
 mod/ping.php              |  2 +-
 mod/profiles.php          |  5 +--
 src/Core/Cache.php        | 16 ++++-----
 src/Core/Worker.php       |  2 +-
 src/Model/Contact.php     | 12 +++----
 src/Model/Profile.php     | 14 ++++----
 src/Module/Login.php      |  2 +-
 src/Object/Post.php       |  2 +-
 src/Protocol/DFRN.php     | 38 ++++++++++----------
 src/Protocol/Diaspora.php | 26 +++++++-------
 src/Protocol/OStatus.php  | 10 +++---
 src/Util/Temporal.php     | 32 +++++++++++------
 src/Worker/Cron.php       | 12 +++----
 src/Worker/OnePoll.php    |  8 ++---
 22 files changed, 173 insertions(+), 128 deletions(-)

diff --git a/include/api.php b/include/api.php
index d20cd03de..c383c5565 100644
--- a/include/api.php
+++ b/include/api.php
@@ -111,7 +111,7 @@ function api_source()
 function api_date($str)
 {
 	// Wed May 23 06:01:13 +0000 2007
-	return Temporal::convert($str, 'UTC', 'UTC', "D M d H:i:s +0000 Y");
+	return Temporal::utc($str, "D M d H:i:s +0000 Y");
 }
 
 /**
@@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type)
 				'@attributes' => ["type" => "integer"],
 				'hourly-limit' => '150',
 				'@attributes2' => ["type" => "integer"],
-				'reset-time' => Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM),
+				'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM),
 				'@attributes3' => ["type" => "datetime"],
 				'reset_time_in_seconds' => strtotime('now + 1 hour'),
 				'@attributes4' => ["type" => "integer"],
@@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type)
 				'reset_time_in_seconds' => strtotime('now + 1 hour'),
 				'remaining_hits' => '150',
 				'hourly_limit' => '150',
-				'reset_time' => api_date(Temporal::convert('now + 1 hour', 'UTC', 'UTC', Temporal::ATOM)),
+				'reset_time' => api_date(Temporal::utc('now + 1 hour', Temporal::ATOM)),
 			];
 	}
 
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 47c5c9891..52031aa72 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -245,17 +245,17 @@ function format_event_diaspora($ev) {
 
 	// @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan
 	$o .= L10n::t('Starts:') . ' ' . '['
-		. (($ev['adjust']) ? day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
-			:  day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format))
+		. (($ev['adjust']) ? day_translate(Temporal::utc($ev['start'], $bd_format))
+			:  day_translate(Temporal::convert($ev['start'], $bd_format))
 		)
-		.  '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['start'])) . ")\n";
+		.  '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n";
 
 	if (! $ev['nofinish']) {
 		$o .= L10n::t('Finishes:') . ' ' . '['
-			. (($ev['adjust']) ? day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
-				:  day_translate(Temporal::convert($ev['finish'], 'UTC', 'UTC', $bd_format))
+			. (($ev['adjust']) ? day_translate(Temporal::utc($ev['finish'], $bd_format))
+				:  day_translate(Temporal::utc($ev['finish'], $bd_format))
 			)
-			. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::convert($ev['finish'])) . ")\n";
+			. '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n";
 	}
 
 	if (strlen($ev['location'])) {
diff --git a/include/event.php b/include/event.php
index c69bd50e0..faa0f9b9f 100644
--- a/include/event.php
+++ b/include/event.php
@@ -26,13 +26,17 @@ 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(Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format))
-		: day_translate(Temporal::convert($ev['start'], 'UTC', 'UTC', $bd_format)));
+	$event_start = day_translate(
+		$ev['adjust'] ?
+			Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format)
+			: Temporal::utc($ev['start'], $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 )));
+	$event_end = day_translate(
+		$ev['adjust'] ?
+			Temporal::convert($ev['finish'], date_default_timezone_get(), 'UTC', $bd_format)
+			: Temporal::utc($ev['finish'], $bd_format)
+	);
 
 	if ($simple) {
 		$o = "

" . bbcode($ev['summary']) . "

"; @@ -57,13 +61,13 @@ function format_event_html($ev, $simple = false) { $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n"; $o .= '
' . L10n::t('Starts:') . ' '.$event_start . '
' . "\r\n"; if (! $ev['nofinish']) { $o .= '
' . L10n::t('Finishes:') . ' '.$event_end . '
' . "\r\n"; } @@ -591,15 +595,15 @@ function process_events($arr) { $fmt = L10n::t('l, F j'); if (count($arr)) { foreach ($arr as $rr) { - $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)); + $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j')); + $d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::utc($rr['start'], $fmt)); $d = day_translate($d); - $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'c')); + $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['start'], 'c')); if ($rr['nofinish']) { $end = null; } else { - $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::convert($rr['finish'], 'UTC', 'UTC', 'c')); + $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['finish'], 'c')); } $is_first = ($d !== $last_date); @@ -924,22 +928,48 @@ 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(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']) ? Temporal::ATOM : 'Y-m-d\TH:i:s')); + $dtstart_dt = day_translate( + $item['event-adjust'] ? + Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat) + : Temporal::utc($item['event-start'], $dformat) + ); + $dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); // Format: Jan till Dec. - $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'))); + $month_short = day_short_translate( + $item['event-adjust'] ? + Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M') + : Temporal::utc($item['event-start'], 'M') + ); // Format: 1 till 31. - $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))); + $date_short = $item['event-adjust'] ? + Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j') + : Temporal::utc($item['event-start'], 'j'); + $start_time = $item['event-adjust'] ? + Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat) + : Temporal::utc($item['event-start'], $tformat); + $start_short = day_short_translate( + $item['event-adjust'] ? + Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short) + : Temporal::utc($item['event-start'], $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(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']) ? Temporal::ATOM : '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)); + $dtend_dt = day_translate( + $item['event-adjust'] ? + Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat) + : Temporal::utc($item['event-finish'], $dformat) + ); + $dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); + $end_short = day_short_translate( + $item['event-adjust'] ? + Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short) + : Temporal::utc($item['event-finish'], $dformat_short) + ); + $end_time = $item['event-adjust'] ? + Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) + : Temporal::utc($item['event-finish'], $tformat); // Check if start and finish time is at the same day. if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) { $same_date = true; diff --git a/include/items.php b/include/items.php index a5ba0718b..83b3484d0 100644 --- a/include/items.php +++ b/include/items.php @@ -437,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 = 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')); + $start_month = Temporal::utc($dstart, 'Y-m-d'); + $end_month = Temporal::utc($dend, 'Y-m-d'); + $str = day_translate(Temporal::utc($dnow, 'F')); if (!$ret[$dyear]) { $ret[$dyear] = []; } $ret[$dyear][] = [$str, $end_month, $start_month]; - $dnow = Temporal::convert($dnow . ' -1 month', 'UTC', 'UTC', 'Y-m-d'); + $dnow = Temporal::utc($dnow . ' -1 month', 'Y-m-d'); } return $ret; } diff --git a/mod/cal.php b/mod/cal.php index 71380373e..10298acee 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -203,8 +203,8 @@ function cal_content(App $a) } } - $start = Temporal::convert($start); - $finish = Temporal::convert($finish); + $start = Temporal::utc($start); + $finish = Temporal::utc($finish); $adjust_start = Temporal::convert($start, date_default_timezone_get()); $adjust_finish = Temporal::convert($finish, date_default_timezone_get()); @@ -231,7 +231,7 @@ function cal_content(App $a) if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j')); + $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'); if (!x($links, $j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 161cd4b1b..6db198dcd 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -241,7 +241,7 @@ function dfrn_request_post(App $a) // Block friend request spam if ($maxreq) { $r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d", - dbesc(Temporal::convert('now - 24 hours')), + dbesc(Temporal::utc('now - 24 hours')), intval($uid) ); if (DBM::is_result($r) && count($r) > $maxreq) { diff --git a/mod/events.php b/mod/events.php index 703b1c0ef..9462b36b0 100644 --- a/mod/events.php +++ b/mod/events.php @@ -81,9 +81,9 @@ function events_post(App $a) { $finish = Temporal::convert($finish, 'UTC', date_default_timezone_get()); } } else { - $start = Temporal::convert($start); + $start = Temporal::utc($start); if (! $nofinish) { - $finish = Temporal::convert($finish); + $finish = Temporal::utc($finish); } } @@ -323,8 +323,8 @@ function events_content(App $a) { } } - $start = Temporal::convert($start); - $finish = Temporal::convert($finish); + $start = Temporal::utc($start); + $finish = Temporal::utc($finish); $adjust_start = Temporal::convert($start, date_default_timezone_get()); $adjust_finish = Temporal::convert($finish, date_default_timezone_get()); @@ -351,7 +351,7 @@ function events_content(App $a) { if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::convert($rr['start'], 'UTC', 'UTC', 'j')); + $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'); if (! x($links,$j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } diff --git a/mod/lostpass.php b/mod/lostpass.php index a34562de7..e3bea9db2 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -92,7 +92,7 @@ function lostpass_content(App $a) } // Password reset requests expire in 60 minutes - if ($user['pwdreset_time'] < Temporal::convert('now - 1 hour')) { + if ($user['pwdreset_time'] < Temporal::utc('now - 1 hour')) { $fields = [ 'pwdreset' => null, 'pwdreset_time' => null diff --git a/mod/ping.php b/mod/ping.php index 9d5a6c409..dd0817d0a 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -225,7 +225,7 @@ function ping_init(App $a) WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 ORDER BY `start` ASC ", intval(local_user()), - dbesc(Temporal::convert('now + 7 days')), + dbesc(Temporal::utc('now + 7 days')), dbesc(Temporal::utcNow()) ); if (DBM::is_result($ev)) { diff --git a/mod/profiles.php b/mod/profiles.php index 6206fdae3..6dfc61f0a 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -218,10 +218,11 @@ function profiles_post(App $a) { $ignore_year = true; $dob = substr($dob, 5); } - $dob = Temporal::convert((($ignore_year) ? '1900-' . $dob : $dob), 'UTC', 'UTC', (($ignore_year) ? 'm-d' : 'Y-m-d')); if ($ignore_year) { - $dob = '0000-' . $dob; + $dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d'); + } else { + $dob = Temporal::utc($dob, 'Y-m-d'); } } diff --git a/src/Core/Cache.php b/src/Core/Cache.php index f77319a46..d6eeb4822 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -165,21 +165,21 @@ class Cache if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) { if ($max_level == CACHE_MONTH) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 30 days"), + Temporal::utc("now - 30 days"), CACHE_MONTH]; dba::delete('cache', $condition); } if ($max_level <= CACHE_WEEK) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 7 days"), + Temporal::utc("now - 7 days"), CACHE_WEEK]; dba::delete('cache', $condition); } if ($max_level <= CACHE_DAY) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 1 days"), + Temporal::utc("now - 1 days"), CACHE_DAY]; dba::delete('cache', $condition); } @@ -188,7 +188,7 @@ class Cache if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 1 hours"), + Temporal::utc("now - 1 hours"), CACHE_HOUR]; dba::delete('cache', $condition); @@ -197,7 +197,7 @@ class Cache if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 30 minutes"), + Temporal::utc("now - 30 minutes"), CACHE_HALF_HOUR]; dba::delete('cache', $condition); @@ -206,7 +206,7 @@ class Cache if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 15 minutes"), + Temporal::utc("now - 15 minutes"), CACHE_QUARTER_HOUR]; dba::delete('cache', $condition); @@ -215,7 +215,7 @@ class Cache if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 5 minutes"), + Temporal::utc("now - 5 minutes"), CACHE_FIVE_MINUTES]; dba::delete('cache', $condition); @@ -224,7 +224,7 @@ class Cache if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) { $condition = ["`updated` < ? AND `expire_mode` = ?", - Temporal::convert("now - 1 minutes"), + Temporal::utc("now - 1 minutes"), CACHE_MINUTE]; dba::delete('cache', $condition); diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 8ff37c019..8ea41c2ef 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -953,7 +953,7 @@ class Worker /// @todo We should clean up the corresponding workerqueue entries as well $condition = ["`created` < ? AND `command` = 'worker.php'", - Temporal::convert("now - ".$timeout." minutes")]; + Temporal::utc("now - ".$timeout." minutes")]; dba::delete('process', $condition); } diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 5afeebad4..212da3334 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -224,7 +224,7 @@ class Contact extends BaseObject /// @todo Check for contact vitality via probing $expiry = $contact['term-date'] . ' + 32 days '; - if (Temporal::utcNow() > Temporal::convert($expiry)) { + if (Temporal::utcNow() > Temporal::utc($expiry)) { /* Relationship is really truly dead. archive them rather than * delete, though if the owner tries to unarchive them we'll start * the whole process over again. @@ -688,7 +688,7 @@ class Contact extends BaseObject $contact_id = $contact["id"]; // Update the contact every 7 days - $update_contact = ($contact['avatar-date'] < Temporal::convert('now -7 days')); + $update_contact = ($contact['avatar-date'] < Temporal::utc('now -7 days')); // We force the update if the avatar is empty if (!x($contact, 'avatar')) { @@ -1485,7 +1485,7 @@ class Contact extends BaseObject foreach ($r as $rr) { logger('update_contact_birthday: ' . $rr['bd']); - $nextbd = Temporal::convert('Y') . substr($rr['bd'], 4); + $nextbd = Temporal::utcNow('Y') . substr($rr['bd'], 4); /* * Add new birthday event for this person @@ -1497,7 +1497,7 @@ class Contact extends BaseObject // Check for duplicates $s = q("SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1", - intval($rr['uid']), intval($rr['id']), dbesc(Temporal::convert($nextbd)), dbesc('birthday')); + intval($rr['uid']), intval($rr['id']), dbesc(Temporal::utc($nextbd)), dbesc('birthday')); if (DBM::is_result($s)) { continue; @@ -1508,8 +1508,8 @@ class Contact extends BaseObject q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']), - dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::convert($nextbd)), - dbesc(Temporal::convert($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'), + dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::utc($nextbd)), + dbesc(Temporal::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'), intval(0) ); diff --git a/src/Model/Profile.php b/src/Model/Profile.php index bdc64a8ac..1cbe5b9b8 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -556,7 +556,7 @@ class Profile WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ? ORDER BY `start` ASC ", local_user(), - Temporal::convert('now + 6 days'), + Temporal::utc('now + 6 days'), Temporal::utcNow() ); if (DBM::is_result($s)) { @@ -644,8 +644,8 @@ class Profile WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ? ORDER BY `start` ASC ", local_user(), - Temporal::convert('now + 7 days'), - Temporal::convert('now - 1 days') + Temporal::utc('now + 7 days'), + Temporal::utc('now - 1 days') ); $r = []; @@ -729,9 +729,11 @@ class Profile $year_bd_format = L10n::t('j F, Y'); $short_bd_format = L10n::t('j F'); - $val = intval($a->profile['dob']) ? - day_translate(Temporal::convert($a->profile['dob'] . ' 00:00 +00:00', 'UTC', 'UTC', $year_bd_format)) - : day_translate(Temporal::convert('2001-' . substr($a->profile['dob'], 'UTC', 'UTC', 5) . ' 00:00 +00:00', $short_bd_format)); + $val = day_translate( + intval($a->profile['dob']) ? + Temporal::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format) + : Temporal::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format) + ); $profile['birthday'] = [L10n::t('Birthday:'), $val]; } diff --git a/src/Module/Login.php b/src/Module/Login.php index e922094d6..0a48392f8 100644 --- a/src/Module/Login.php +++ b/src/Module/Login.php @@ -222,7 +222,7 @@ class Login extends BaseModule if (!x($_SESSION['last_login_date'])) { $_SESSION['last_login_date'] = Temporal::utcNow(); } - if (strcmp(Temporal::convert('now - 12 hours'), $_SESSION['last_login_date']) > 0) { + if (strcmp(Temporal::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) { $_SESSION['last_login_date'] = Temporal::utcNow(); $login_refresh = true; } diff --git a/src/Object/Post.php b/src/Object/Post.php index 4797850a4..be3018cc9 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -301,7 +301,7 @@ class Post extends BaseObject $comment = $this->getCommentBox($indent); - if (strcmp(Temporal::convert($item['created']), Temporal::convert('now - 12 hours')) > 0) { + if (strcmp(Temporal::utc($item['created']), Temporal::utc('now - 12 hours')) > 0) { $shiny = 'shiny'; } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 998a6022f..9eb226689 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -229,7 +229,7 @@ class DFRN } } - $check_date = Temporal::convert($last_update); + $check_date = Temporal::utc($last_update); $r = q( "SELECT `item`.*, `item`.`id` AS `item_id`, @@ -421,7 +421,7 @@ class DFRN XML::addElement($doc, $mail, "dfrn:id", $item['uri']); XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']); - XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::convert($item['created'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)); + XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::utc($item['created'] . '+00:00', Temporal::ATOM)); XML::addElement($doc, $mail, "dfrn:subject", $item['title']); XML::addElement($doc, $mail, "dfrn:content", $item['body']); @@ -587,7 +587,7 @@ class DFRN /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP" - XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM)); $author = self::addAuthor($doc, $owner, $authorelement, $public); $root->appendChild($author); @@ -622,9 +622,9 @@ class DFRN $author = $doc->createElement($authorelement); - $namdate = Temporal::convert($owner['name-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); - $uridate = Temporal::convert($owner['uri-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); - $picdate = Temporal::convert($owner['avatar-date'].'+00:00', 'UTC', 'UTC', Temporal::ATOM); + $namdate = Temporal::utc($owner['name-date'].'+00:00', Temporal::ATOM); + $uridate = Temporal::utc($owner['uri-date'].'+00:00', Temporal::ATOM); + $picdate = Temporal::utc($owner['avatar-date'].'+00:00', Temporal::ATOM); $attributes = []; @@ -903,7 +903,7 @@ class DFRN } if ($item['deleted']) { - $attributes = ["ref" => $item['uri'], "when" => Temporal::convert($item['edited'] . '+00:00', 'UTC', 'UTC', Temporal::ATOM)]; + $attributes = ["ref" => $item['uri'], "when" => Temporal::utc($item['edited'] . '+00:00', Temporal::ATOM)]; return XML::createElement($doc, "at:deleted-entry", "", $attributes); } @@ -983,8 +983,8 @@ class DFRN XML::addElement($doc, $entry, "id", $item["uri"]); XML::addElement($doc, $entry, "title", $item["title"]); - XML::addElement($doc, $entry, "published", Temporal::convert($item["created"] . "+00:00", "UTC", "UTC", Temporal::ATOM)); - XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"] . "+00:00", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $entry, "published", Temporal::utc($item["created"] . "+00:00", Temporal::ATOM)); + XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"] . "+00:00", Temporal::ATOM)); // "dfrn:env" is used to read the content XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true)); @@ -1388,7 +1388,7 @@ class DFRN "SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1", intval($contact["uid"]), intval($contact["id"]), - dbesc(Temporal::convert($birthday)), + dbesc(Temporal::utc($birthday)), dbesc("birthday") ); @@ -1408,8 +1408,8 @@ class DFRN intval($contact["id"]), dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), - dbesc(Temporal::convert($birthday)), - dbesc(Temporal::convert($birthday . " + 1 day ")), + dbesc(Temporal::utc($birthday)), + dbesc(Temporal::utc($birthday . " + 1 day ")), dbesc($bdtext), dbesc($bdtext2), dbesc("birthday") @@ -2081,13 +2081,13 @@ class DFRN if (self::isEditedTimestampNewer($current, $item)) { // do not accept (ignore) an earlier edit than one we currently have. - if (Temporal::convert($item["edited"]) < $current["edited"]) { + if (Temporal::utc($item["edited"]) < $current["edited"]) { return false; } $fields = ['title' => $item["title"], 'body' => $item["body"], 'tag' => $item["tag"], 'changed' => Temporal::utcNow(), - 'edited' => Temporal::convert($item["edited"])]; + 'edited' => Temporal::utc($item["edited"])]; $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]]; dba::update('item', $fields, $condition); @@ -2422,7 +2422,7 @@ class DFRN // Is there an existing item? if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item) - && (Temporal::convert($item["edited"]) < $current[0]["edited"]) + && (Temporal::utc($item["edited"]) < $current[0]["edited"]) ) { logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG); return; @@ -2753,9 +2753,9 @@ class DFRN } } if ($when) { - $when = Temporal::convert($when); + $when = Temporal::utc($when); } else { - $when = Temporal::convert("now"); + $when = Temporal::utcNow(); } if (!$uri || !$importer["id"]) { @@ -3157,8 +3157,8 @@ class DFRN return false; } - $existing_edited = Temporal::convert($existing['edited']); - $update_edited = Temporal::convert($update['edited']); + $existing_edited = Temporal::utc($existing['edited']); + $update_edited = Temporal::utc($update['edited']); return (strcmp($existing_edited, $update_edited) < 0); } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index afd735965..077c93c29 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1654,7 +1654,7 @@ class Diaspora $text = unxmlify($data->text); if (isset($data->created_at)) { - $created_at = Temporal::convert(notags(unxmlify($data->created_at))); + $created_at = Temporal::utc(notags(unxmlify($data->created_at))); } else { $created_at = Temporal::utcNow(); } @@ -1786,7 +1786,7 @@ class Diaspora $msg_guid = notags(unxmlify($mesg->guid)); $msg_conversation_guid = notags(unxmlify($mesg->conversation_guid)); $msg_text = unxmlify($mesg->text); - $msg_created_at = Temporal::convert(notags(unxmlify($mesg->created_at))); + $msg_created_at = Temporal::utc(notags(unxmlify($mesg->created_at))); if ($msg_conversation_guid != $guid) { logger("message conversation guid does not belong to the current conversation."); @@ -1865,7 +1865,7 @@ class Diaspora $author = notags(unxmlify($data->author)); $guid = notags(unxmlify($data->guid)); $subject = notags(unxmlify($data->subject)); - $created_at = Temporal::convert(notags(unxmlify($data->created_at))); + $created_at = Temporal::utc(notags(unxmlify($data->created_at))); $participants = notags(unxmlify($data->participants)); $messages = $data->message; @@ -2098,7 +2098,7 @@ class Diaspora $guid = notags(unxmlify($data->guid)); $conversation_guid = notags(unxmlify($data->conversation_guid)); $text = unxmlify($data->text); - $created_at = Temporal::convert(notags(unxmlify($data->created_at))); + $created_at = Temporal::utc(notags(unxmlify($data->created_at))); $contact = self::allowedContactByHandle($importer, $author, true); if (!$contact) { @@ -2315,7 +2315,7 @@ class Diaspora $birthday = str_replace("1000", "1901", $birthday); if ($birthday != "") { - $birthday = Temporal::convert($birthday, "UTC", "UTC", "Y-m-d"); + $birthday = Temporal::utc($birthday, "Y-m-d"); } // this is to prevent multiple birthday notifications in a single year @@ -2716,7 +2716,7 @@ class Diaspora { $author = notags(unxmlify($data->author)); $guid = notags(unxmlify($data->guid)); - $created_at = Temporal::convert(notags(unxmlify($data->created_at))); + $created_at = Temporal::utc(notags(unxmlify($data->created_at))); $root_author = notags(unxmlify($data->root_author)); $root_guid = notags(unxmlify($data->root_guid)); /// @todo handle unprocessed property "provider_display_name" @@ -2930,7 +2930,7 @@ class Diaspora { $author = notags(unxmlify($data->author)); $guid = notags(unxmlify($data->guid)); - $created_at = Temporal::convert(notags(unxmlify($data->created_at))); + $created_at = Temporal::utc(notags(unxmlify($data->created_at))); $public = notags(unxmlify($data->public)); $text = unxmlify($data->text); $provider_display_name = notags(unxmlify($data->provider_display_name)); @@ -3652,7 +3652,7 @@ class Diaspora $public = (($item["private"]) ? "false" : "true"); - $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); + $created = Temporal::utc($item["created"], Temporal::ATOM); // Detect a share element and do a reshare if (!$item['private'] && ($ret = self::isReshare($item["body"]))) { @@ -3855,7 +3855,7 @@ class Diaspora $parent = $p[0]; $text = html_entity_decode(bb2diaspora($item["body"])); - $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); + $created = Temporal::utc($item["created"], Temporal::ATOM); $comment = ["author" => self::myHandle($owner), "guid" => $item["guid"], @@ -4086,12 +4086,12 @@ class Diaspora "author" => $cnv["creator"], "guid" => $cnv["guid"], "subject" => $cnv["subject"], - "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM), + "created_at" => Temporal::utc($cnv['created'], Temporal::ATOM), "participants" => $cnv["recips"] ]; $body = bb2diaspora($item["body"]); - $created = Temporal::convert($item["created"], "UTC", "UTC", Temporal::ATOM); + $created = Temporal::utc($item["created"], Temporal::ATOM); $msg = [ "author" => $myaddr, @@ -4109,7 +4109,7 @@ class Diaspora "author" => $cnv["creator"], "guid" => $cnv["guid"], "subject" => $cnv["subject"], - "created_at" => Temporal::convert($cnv['created'], "UTC", "UTC", Temporal::ATOM), + "created_at" => Temporal::utc($cnv['created'], Temporal::ATOM), "participants" => $cnv["recips"], "message" => $msg]; @@ -4217,7 +4217,7 @@ class Diaspora if ($year < 1004) { $year = 1004; } - $dob = Temporal::convert($year . '-' . $month . '-'. $day, 'UTC', 'UTC', 'Y-m-d'); + $dob = Temporal::utc($year . '-' . $month . '-'. $day, 'Y-m-d'); } $about = $profile['about']; diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index c98b8ddec..0583e0cee 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1273,7 +1273,7 @@ class OStatus XML::addElement($doc, $root, "title", $title); XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"])); XML::addElement($doc, $root, "logo", $owner["photo"]); - XML::addElement($doc, $root, "updated", Temporal::convert("now", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM)); $author = self::addAuthor($doc, $owner); $root->appendChild($author); @@ -1539,7 +1539,7 @@ class OStatus XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]); XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]); XML::addElement($doc, $source, "icon", $contact["photo"]); - XML::addElement($doc, $source, "updated", Temporal::convert($contact["success_update"]."+00:00", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $source, "updated", Temporal::utc($contact["success_update"]."+00:00", Temporal::ATOM)); return $source; } @@ -1923,8 +1923,8 @@ class OStatus XML::addElement($doc, $entry, "activity:verb", $verb); - XML::addElement($doc, $entry, "published", Temporal::convert($item["created"]."+00:00", "UTC", "UTC", Temporal::ATOM)); - XML::addElement($doc, $entry, "updated", Temporal::convert($item["edited"]."+00:00", "UTC", "UTC", Temporal::ATOM)); + XML::addElement($doc, $entry, "published", Temporal::utc($item["created"]."+00:00", Temporal::ATOM)); + XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"]."+00:00", Temporal::ATOM)); } /** @@ -2127,7 +2127,7 @@ class OStatus $last_update = 'now -30 days'; } - $check_date = Temporal::convert($last_update); + $check_date = Temporal::utc($last_update); $authorid = Contact::getIdForURL($owner["url"], 0); $sql_extra = ''; diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index eb0bbeb8e..a2d4677f2 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -113,7 +113,7 @@ class Temporal */ public static function getTimezoneField($name = 'timezone', $label = '', $current = 'America/Los_Angeles', $help = '') { - $options = Temporal::getTimezoneSelect($current); + $options = self::getTimezoneSelect($current); $options = str_replace('', '', $options); @@ -123,6 +123,18 @@ class Temporal ]); } + /** + * convert() shorthand for UTC. + * + * @param string $time A date/time string + * @param string $format DateTime format string or Temporal constant + * @return string + */ + public static function utc($time, $format = self::MYSQL) + { + return self::convert($time, 'UTC', 'UTC', $format); + } + /** * convert() shorthand for UTC now. * @@ -209,7 +221,7 @@ class Temporal if ($dob < '0000-01-01') { $value = ''; } else { - $value = Temporal::convert(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'UTC', 'UTC', 'Y-m-d'); + $value = self::utc(($year > 1000) ? $dob : '1000-' . $month . '-' . $day, 'Y-m-d'); } $age = (intval($value) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); @@ -445,11 +457,11 @@ class Temporal $viewer_tz = date_default_timezone_get(); } - $birthdate = Temporal::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d'); + $birthdate = self::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d'); list($year, $month, $day) = explode("-", $birthdate); - $year_diff = Temporal::convert('now', $viewer_tz, 'UTC', 'Y') - $year; - $curr_month = Temporal::convert('now', $viewer_tz, 'UTC', 'm'); - $curr_day = Temporal::convert('now', $viewer_tz, 'UTC', 'd'); + $year_diff = self::convert('now', $viewer_tz, 'UTC', 'Y') - $year; + $curr_month = self::convert('now', $viewer_tz, 'UTC', 'm'); + $curr_day = self::convert('now', $viewer_tz, 'UTC', 'd'); if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) { $year_diff--; @@ -489,7 +501,7 @@ class Temporal { $d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m)); - return Temporal::convert($d, 'UTC', 'UTC', 'w'); + return self::utc($d, 'w'); } /** @@ -519,8 +531,8 @@ class Temporal 'October', 'November', 'December' ]; - $thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); - $thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm'); + $thisyear = self::convert('now', date_default_timezone_get(), 'UTC', 'Y'); + $thismonth = self::convert('now', date_default_timezone_get(), 'UTC', 'm'); if (!$y) { $y = $thisyear; } @@ -537,7 +549,7 @@ class Temporal $started = false; if (($y == $thisyear) && ($m == $thismonth)) { - $tddate = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'j')); + $tddate = intval(self::convert('now', date_default_timezone_get(), 'UTC', 'j')); } $str_month = day_translate($mtab[$m]); diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 07ddf8bee..9c68a7fea 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -218,33 +218,33 @@ Class Cron { */ switch ($contact['priority']) { case 5: - if (Temporal::utcNow() > Temporal::convert($t . " + 1 month")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 1 month")) { $update = true; } break; case 4: - if (Temporal::utcNow() > Temporal::convert($t . " + 1 week")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 1 week")) { $update = true; } break; case 3: - if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) { $update = true; } break; case 2: - if (Temporal::utcNow() > Temporal::convert($t . " + 12 hour")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 12 hour")) { $update = true; } break; case 1: - if (Temporal::utcNow() > Temporal::convert($t . " + 1 hour")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 1 hour")) { $update = true; } break; case 0: default: - if (Temporal::utcNow() > Temporal::convert($t . " + ".$min_poll_interval." minute")) { + if (Temporal::utcNow() > Temporal::utc($t . " + ".$min_poll_interval." minute")) { $update = true; } break; diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 6e69bc3aa..0a39aafec 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -99,7 +99,7 @@ class OnePoll $contact['priority'] = intval($poll_interval); $hub_update = false; - if (Temporal::utcNow() > Temporal::convert($t . " + 1 day")) { + if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) { $hub_update = true; } } else { @@ -107,8 +107,8 @@ class OnePoll } $last_update = (($contact['last-update'] <= NULL_DATE) - ? Temporal::convert('now - 7 days', 'UTC', 'UTC', Temporal::ATOM) - : Temporal::convert($contact['last-update'], 'UTC', 'UTC', Temporal::ATOM) + ? Temporal::utc('now - 7 days', Temporal::ATOM) + : Temporal::utc($contact['last-update'], Temporal::ATOM) ); // Update the contact entry @@ -459,7 +459,7 @@ class OnePoll $datarray['title'] = notags(trim($datarray['title'])); //$datarray['title'] = notags(trim($meta->subject)); - $datarray['created'] = Temporal::convert($meta->date); + $datarray['created'] = Temporal::utc($meta->date); // Is it a reply? $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") || From 89602e44da535697dcf33aa37e43cce317d4830c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:14:15 -0500 Subject: [PATCH 11/24] Add Temporal::timezoneNow() shorthand for Temporal::convert() --- boot.php | 4 ++-- include/items.php | 4 ++-- mod/cal.php | 4 ++-- mod/events.php | 4 ++-- mod/photos.php | 4 ++-- mod/ping.php | 2 +- src/Model/Profile.php | 6 +++--- src/Util/Temporal.php | 23 +++++++++++++++++------ 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/boot.php b/boot.php index 18c76587c..66e4645e5 100644 --- a/boot.php +++ b/boot.php @@ -1142,10 +1142,10 @@ function feed_birthday($uid, $tz) if (DBM::is_result($p)) { $tmp_dob = substr($p[0]['dob'], 5); if (intval($tmp_dob)) { - $y = Temporal::convert('now', $tz, $tz, 'Y'); + $y = Temporal::timezoneNow($tz, 'Y'); $bd = $y . '-' . $tmp_dob . ' 00:00'; $t_dob = strtotime($bd); - $now = strtotime(Temporal::convert('now', $tz, $tz)); + $now = strtotime(Temporal::timezoneNow($tz)); if ($t_dob < $now) { $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; } diff --git a/include/items.php b/include/items.php index 83b3484d0..b5ec592e0 100644 --- a/include/items.php +++ b/include/items.php @@ -416,7 +416,7 @@ function drop_item($id) { /* arrange the list in years */ function list_post_dates($uid, $wall) { - $dnow = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y-m-d'); + $dnow = Temporal::timezoneNow(date_default_timezone_get(), 'Y-m-d'); $dthen = Item::firstPostDate($uid, $wall); if (!$dthen) { @@ -474,7 +474,7 @@ function posted_date_widget($url, $uid, $wall) { return $o; } - $cutoff_year = intval(Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y')) - $visible_years; + $cutoff_year = intval(Temporal::timezoneNow(date_default_timezone_get(), 'Y')) - $visible_years; $cutoff = ((array_key_exists($cutoff_year, $ret))? true : false); $o = replace_macros(get_markup_template('posted_date_widget.tpl'),[ diff --git a/mod/cal.php b/mod/cal.php index 10298acee..11a1a5e6f 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -152,8 +152,8 @@ function cal_content(App $a) // The view mode part is similiar to /mod/events.php if ($mode == 'view') { - $thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); - $thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm'); + $thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); + $thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm'); if (!$y) { $y = intval($thisyear); } diff --git a/mod/events.php b/mod/events.php index 9462b36b0..aad56f43a 100644 --- a/mod/events.php +++ b/mod/events.php @@ -276,8 +276,8 @@ function events_content(App $a) { // The view mode part is similiar to /mod/cal.php if ($mode == 'view') { - $thisyear = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); - $thismonth = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'm'); + $thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); + $thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm'); if (! $y) { $y = intval($thisyear); } diff --git a/mod/photos.php b/mod/photos.php index a7ed50a44..dac52b1d0 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -402,7 +402,7 @@ function photos_post(App $a) $resource_id = $a->argv[2]; if (!strlen($albname)) { - $albname = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); + $albname = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); } if (x($_POST,'rotate') !== false && @@ -738,7 +738,7 @@ function photos_post(App $a) if (strlen($newalbum)) { $album = $newalbum; } else { - $album = Temporal::convert('now', date_default_timezone_get(), 'UTC', 'Y'); + $album = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); } } diff --git a/mod/ping.php b/mod/ping.php index dd0817d0a..d26fc61be 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -237,7 +237,7 @@ function ping_init(App $a) $all_events = count($ev); if ($all_events) { - $str_now = Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d'); + $str_now = Temporal::timezoneNow($a->timezone, 'Y-m-d'); foreach ($ev as $x) { $bd = false; if ($x['type'] === 'birthday') { diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 1cbe5b9b8..aeb7155f1 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -659,7 +659,7 @@ class Profile } $strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d'); - if ($strt === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) { + if ($strt === Temporal::timezoneNow($a->timezone, 'Y-m-d')) { $istoday = true; } @@ -676,11 +676,11 @@ class Profile $strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC'); - if (substr($strt, 0, 10) < Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) { + if (substr($strt, 0, 10) < Temporal::timezoneNow($a->timezone, 'Y-m-d')) { continue; } - $today = ((substr($strt, 0, 10) === Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d')) ? true : false); + $today = ((substr($strt, 0, 10) === Temporal::timezoneNow($a->timezone, 'Y-m-d')) ? true : false); $rr['title'] = $title; $rr['description'] = $description; diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index a2d4677f2..37be4eb91 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -135,6 +135,17 @@ class Temporal return self::convert($time, 'UTC', 'UTC', $format); } + /** + * convert() shorthand for UTC now. + * + * @param string $format DateTime format string or Temporal constant + * @return string + */ + public static function timezoneNow($timezone, $format = self::MYSQL) + { + return self::convert('now', $timezone, 'UTC', $format); + } + /** * convert() shorthand for UTC now. * @@ -459,9 +470,9 @@ class Temporal $birthdate = self::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d'); list($year, $month, $day) = explode("-", $birthdate); - $year_diff = self::convert('now', $viewer_tz, 'UTC', 'Y') - $year; - $curr_month = self::convert('now', $viewer_tz, 'UTC', 'm'); - $curr_day = self::convert('now', $viewer_tz, 'UTC', 'd'); + $year_diff = self::timezoneNow($viewer_tz, 'Y') - $year; + $curr_month = self::timezoneNow($viewer_tz, 'm'); + $curr_day = self::timezoneNow($viewer_tz, 'd'); if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) { $year_diff--; @@ -531,8 +542,8 @@ class Temporal 'October', 'November', 'December' ]; - $thisyear = self::convert('now', date_default_timezone_get(), 'UTC', 'Y'); - $thismonth = self::convert('now', date_default_timezone_get(), 'UTC', 'm'); + $thisyear = self::timezoneNow(date_default_timezone_get(), 'Y'); + $thismonth = self::timezoneNow(date_default_timezone_get(), 'm'); if (!$y) { $y = $thisyear; } @@ -549,7 +560,7 @@ class Temporal $started = false; if (($y == $thisyear) && ($m == $thismonth)) { - $tddate = intval(self::convert('now', date_default_timezone_get(), 'UTC', 'j')); + $tddate = intval(self::timezoneNow(date_default_timezone_get(), 'j')); } $str_month = day_translate($mtab[$m]); From a2ee2b56d219846d43a2214fbf9cbb9e325e5826 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:16:22 -0500 Subject: [PATCH 12/24] Add Temporal::localNow() shorthand for Temporal::convert() --- include/items.php | 4 ++-- mod/cal.php | 4 ++-- mod/events.php | 4 ++-- mod/photos.php | 4 ++-- src/Util/Temporal.php | 19 +++++++++++++++---- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/items.php b/include/items.php index b5ec592e0..e5a04b120 100644 --- a/include/items.php +++ b/include/items.php @@ -416,7 +416,7 @@ function drop_item($id) { /* arrange the list in years */ function list_post_dates($uid, $wall) { - $dnow = Temporal::timezoneNow(date_default_timezone_get(), 'Y-m-d'); + $dnow = Temporal::localNow('Y-m-d'); $dthen = Item::firstPostDate($uid, $wall); if (!$dthen) { @@ -474,7 +474,7 @@ function posted_date_widget($url, $uid, $wall) { return $o; } - $cutoff_year = intval(Temporal::timezoneNow(date_default_timezone_get(), 'Y')) - $visible_years; + $cutoff_year = intval(Temporal::localNow('Y')) - $visible_years; $cutoff = ((array_key_exists($cutoff_year, $ret))? true : false); $o = replace_macros(get_markup_template('posted_date_widget.tpl'),[ diff --git a/mod/cal.php b/mod/cal.php index 11a1a5e6f..d48ce1c5e 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -152,8 +152,8 @@ function cal_content(App $a) // The view mode part is similiar to /mod/events.php if ($mode == 'view') { - $thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); - $thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm'); + $thisyear = Temporal::localNow('Y'); + $thismonth = Temporal::localNow('m'); if (!$y) { $y = intval($thisyear); } diff --git a/mod/events.php b/mod/events.php index aad56f43a..028e23e51 100644 --- a/mod/events.php +++ b/mod/events.php @@ -276,8 +276,8 @@ function events_content(App $a) { // The view mode part is similiar to /mod/cal.php if ($mode == 'view') { - $thisyear = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); - $thismonth = Temporal::timezoneNow(date_default_timezone_get(), 'm'); + $thisyear = Temporal::localNow('Y'); + $thismonth = Temporal::localNow('m'); if (! $y) { $y = intval($thisyear); } diff --git a/mod/photos.php b/mod/photos.php index dac52b1d0..49b68a345 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -402,7 +402,7 @@ function photos_post(App $a) $resource_id = $a->argv[2]; if (!strlen($albname)) { - $albname = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); + $albname = Temporal::localNow('Y'); } if (x($_POST,'rotate') !== false && @@ -738,7 +738,7 @@ function photos_post(App $a) if (strlen($newalbum)) { $album = $newalbum; } else { - $album = Temporal::timezoneNow(date_default_timezone_get(), 'Y'); + $album = Temporal::localNow('Y'); } } diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 37be4eb91..8deadd5e8 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -136,7 +136,7 @@ class Temporal } /** - * convert() shorthand for UTC now. + * convert() shorthand for timezoned now. * * @param string $format DateTime format string or Temporal constant * @return string @@ -146,6 +146,17 @@ class Temporal return self::convert('now', $timezone, 'UTC', $format); } + /** + * convert() shorthand for local now. + * + * @param string $format DateTime format string or Temporal constant + * @return string + */ + public static function localNow($format = self::MYSQL) + { + return self::convert('now', date_default_timezone_get(), 'UTC', $format); + } + /** * convert() shorthand for UTC now. * @@ -542,8 +553,8 @@ class Temporal 'October', 'November', 'December' ]; - $thisyear = self::timezoneNow(date_default_timezone_get(), 'Y'); - $thismonth = self::timezoneNow(date_default_timezone_get(), 'm'); + $thisyear = self::localNow('Y'); + $thismonth = self::localNow('m'); if (!$y) { $y = $thisyear; } @@ -560,7 +571,7 @@ class Temporal $started = false; if (($y == $thisyear) && ($m == $thismonth)) { - $tddate = intval(self::timezoneNow(date_default_timezone_get(), 'j')); + $tddate = intval(self::localNow('j')); } $str_month = day_translate($mtab[$m]); From 25954314ec156059848352dd0e4eb896eb28be5c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:18:06 -0500 Subject: [PATCH 13/24] Add missing Temporal::utc() --- include/bb2diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 52031aa72..5808e64ed 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -246,7 +246,7 @@ function format_event_diaspora($ev) { // @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan $o .= L10n::t('Starts:') . ' ' . '[' . (($ev['adjust']) ? day_translate(Temporal::utc($ev['start'], $bd_format)) - : day_translate(Temporal::convert($ev['start'], $bd_format)) + : day_translate(Temporal::utc($ev['start'], $bd_format)) ) . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n"; From 0bee706e515c9dbbe17dab6eeb6887b33a15f1c0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:29:06 -0500 Subject: [PATCH 14/24] Add Temporal::local() shorthand for Temporal::convert() --- include/conversation.php | 2 +- include/event.php | 32 +++++++++++++++---------------- mod/cal.php | 6 +++--- mod/contacts.php | 2 +- mod/events.php | 6 +++--- mod/message.php | 4 ++-- mod/ping.php | 2 +- mod/profiles.php | 2 +- src/Core/NotificationsManager.php | 8 ++++---- src/Object/Post.php | 4 ++-- src/Util/Temporal.php | 16 ++++++++++++++-- 11 files changed, 48 insertions(+), 36 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 755f24764..98cb1773b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -790,7 +790,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body_e), - 'localtime' => Temporal::convert($item['created'], date_default_timezone_get(), 'UTC', 'r'), + 'localtime' => Temporal::local($item['created'], 'r'), 'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])), 'location' => $location_e, 'indent' => '', diff --git a/include/event.php b/include/event.php index faa0f9b9f..95be09cd7 100644 --- a/include/event.php +++ b/include/event.php @@ -28,13 +28,13 @@ function format_event_html($ev, $simple = false) { $event_start = day_translate( $ev['adjust'] ? - Temporal::convert($ev['start'], date_default_timezone_get(), 'UTC', $bd_format) + Temporal::local($ev['start'], $bd_format) : Temporal::utc($ev['start'], $bd_format) ); $event_end = day_translate( $ev['adjust'] ? - Temporal::convert($ev['finish'], date_default_timezone_get(), 'UTC', $bd_format) + Temporal::local($ev['finish'], $bd_format) : Temporal::utc($ev['finish'], $bd_format) ); @@ -200,8 +200,8 @@ function sort_by_date($a) { function ev_compare($a,$b) { - $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']); + $date_a = (($a['adjust']) ? Temporal::local($a['start']) : $a['start']); + $date_b = (($b['adjust']) ? Temporal::local($b['start']) : $b['start']); if ($date_a === $date_b) { return strcasecmp($a['desc'], $b['desc']); @@ -595,15 +595,15 @@ function process_events($arr) { $fmt = L10n::t('l, F j'); if (count($arr)) { foreach ($arr as $rr) { - $j = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j')); - $d = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', $fmt) : Temporal::utc($rr['start'], $fmt)); + $j = (($rr['adjust']) ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j')); + $d = (($rr['adjust']) ? Temporal::local($rr['start'], $fmt) : Temporal::utc($rr['start'], $fmt)); $d = day_translate($d); - $start = (($rr['adjust']) ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['start'], 'c')); + $start = (($rr['adjust']) ? Temporal::local($rr['start'], 'c') : Temporal::utc($rr['start'], 'c')); if ($rr['nofinish']) { $end = null; } else { - $end = (($rr['adjust']) ? Temporal::convert($rr['finish'], date_default_timezone_get(), 'UTC', 'c') : Temporal::utc($rr['finish'], 'c')); + $end = (($rr['adjust']) ? Temporal::local($rr['finish'], 'c') : Temporal::utc($rr['finish'], 'c')); } $is_first = ($d !== $last_date); @@ -930,26 +930,26 @@ function format_event_item($item) { // Convert the time to different formats. $dtstart_dt = day_translate( $item['event-adjust'] ? - Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat) + Temporal::local($item['event-start'], $dformat) : Temporal::utc($item['event-start'], $dformat) ); $dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); // Format: Jan till Dec. $month_short = day_short_translate( $item['event-adjust'] ? - Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'M') + Temporal::local($item['event-start'], 'M') : Temporal::utc($item['event-start'], 'M') ); // Format: 1 till 31. $date_short = $item['event-adjust'] ? - Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', 'j') + Temporal::local($item['event-start'], 'j') : Temporal::utc($item['event-start'], 'j'); $start_time = $item['event-adjust'] ? - Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $tformat) + Temporal::local($item['event-start'], $tformat) : Temporal::utc($item['event-start'], $tformat); $start_short = day_short_translate( $item['event-adjust'] ? - Temporal::convert($item['event-start'], date_default_timezone_get(), 'UTC', $dformat_short) + Temporal::local($item['event-start'], $dformat_short) : Temporal::utc($item['event-start'], $dformat_short) ); @@ -958,17 +958,17 @@ function format_event_item($item) { $finish = true; $dtend_dt = day_translate( $item['event-adjust'] ? - Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat) + Temporal::local($item['event-finish'], $dformat) : Temporal::utc($item['event-finish'], $dformat) ); $dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); $end_short = day_short_translate( $item['event-adjust'] ? - Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $dformat_short) + Temporal::local($item['event-finish'], $dformat_short) : Temporal::utc($item['event-finish'], $dformat_short) ); $end_time = $item['event-adjust'] ? - Temporal::convert($item['event-finish'], date_default_timezone_get(), 'UTC', $tformat) + Temporal::local($item['event-finish'], $tformat) : Temporal::utc($item['event-finish'], $tformat); // Check if start and finish time is at the same day. if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) { diff --git a/mod/cal.php b/mod/cal.php index d48ce1c5e..22005c06a 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -206,8 +206,8 @@ function cal_content(App $a) $start = Temporal::utc($start); $finish = Temporal::utc($finish); - $adjust_start = Temporal::convert($start, date_default_timezone_get()); - $adjust_finish = Temporal::convert($finish, date_default_timezone_get()); + $adjust_start = Temporal::local($start); + $adjust_finish = Temporal::local($finish); // put the event parametes in an array so we can better transmit them $event_params = [ @@ -231,7 +231,7 @@ function cal_content(App $a) if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'); + $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); if (!x($links, $j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } diff --git a/mod/contacts.php b/mod/contacts.php index 6bd6f753f..81f1a6caf 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -540,7 +540,7 @@ function contacts_content(App $a) $insecure = L10n::t('Private communications are not available for this contact.'); - $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::convert($contact['last-update'], date_default_timezone_get(), 'UTC', 'D, j M Y, g:i A')); + $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::local($contact['last-update'], 'D, j M Y, g:i A')); if ($contact['last-update'] > NULL_DATE) { $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29")); diff --git a/mod/events.php b/mod/events.php index 028e23e51..1d61dfcc3 100644 --- a/mod/events.php +++ b/mod/events.php @@ -326,8 +326,8 @@ function events_content(App $a) { $start = Temporal::utc($start); $finish = Temporal::utc($finish); - $adjust_start = Temporal::convert($start, date_default_timezone_get()); - $adjust_finish = Temporal::convert($finish, date_default_timezone_get()); + $adjust_start = Temporal::local($start); + $adjust_finish = Temporal::local($finish); // put the event parametes in an array so we can better transmit them $event_params = [ @@ -351,7 +351,7 @@ function events_content(App $a) { if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = $rr['adjust'] ? Temporal::convert($rr['start'], date_default_timezone_get(), 'UTC', 'j') : Temporal::utc($rr['start'], 'j'); + $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); if (! x($links,$j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } diff --git a/mod/message.php b/mod/message.php index c1b2d989e..5f1efe5ba 100644 --- a/mod/message.php +++ b/mod/message.php @@ -397,7 +397,7 @@ function message_content(App $a) 'body' => $body_e, 'delete' => L10n::t('Delete message'), 'to_name' => $to_name_e, - 'date' => Temporal::convert($message['created'], date_default_timezone_get(), 'UTC', 'D, d M Y - g:i A'), + 'date' => Temporal::local($message['created'], 'D, d M Y - g:i A'), 'ago' => relative_date($message['created']), ]; @@ -498,7 +498,7 @@ function render_messages(array $msg, $t) '$delete' => L10n::t('Delete conversation'), '$body' => $body_e, '$to_name' => $to_name_e, - '$date' => Temporal::convert($rr['mailcreated'], date_default_timezone_get(), 'UTC', L10n::t('D, d M Y - g:i A')), + '$date' => Temporal::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')), '$ago' => relative_date($rr['mailcreated']), '$seen' => $rr['mailseen'], '$count' => L10n::tt('%d message', '%d messages', $rr['count']), diff --git a/mod/ping.php b/mod/ping.php index d26fc61be..56d5fe290 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -362,7 +362,7 @@ function ping_init(App $a) $notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO); } - $local_time = Temporal::convert($notif['date'], date_default_timezone_get()); + $local_time = Temporal::local($notif['date']); $notifications[] = [ 'id' => $notif['id'], diff --git a/mod/profiles.php b/mod/profiles.php index 6dfc61f0a..25ce15ce8 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -725,7 +725,7 @@ function profiles_content(App $a) { '$gender' => ContactSelector::gender($r[0]['gender']), '$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')], - '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::convert($r[0]['howlong'], date_default_timezone_get()))], + '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::local($r[0]['howlong']))], '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']), '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']], '$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")], diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 8853c16d5..a28dfbb06 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -43,7 +43,7 @@ class NotificationsManager extends BaseObject { $rets = []; foreach ($notes as $n) { - $local_time = Temporal::convert($n['date'], date_default_timezone_get()); + $local_time = Temporal::local($n['date']); $n['timestamp'] = strtotime($local_time); $n['date_rel'] = relative_date($n['date']); $n['msg_html'] = bbcode($n['msg'], false, false, false, false); @@ -244,7 +244,7 @@ class NotificationsManager extends BaseObject $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO); $default_item_url = $it['url']; $default_item_text = strip_tags(bbcode($it['msg'])); - $default_item_when = Temporal::convert($it['date'], date_default_timezone_get(), 'UTC', 'r'); + $default_item_when = Temporal::local($it['date'], 'r'); $default_item_ago = relative_date($it['date']); break; @@ -254,7 +254,7 @@ class NotificationsManager extends BaseObject $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO); $default_item_url = $it['author-link']; $default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']); - $default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r'); + $default_item_when = Temporal::local($it['created'], 'r'); $default_item_ago = relative_date($it['created']); break; @@ -266,7 +266,7 @@ class NotificationsManager extends BaseObject $default_item_text = (($it['id'] == $it['parent']) ? L10n::t("%s created a new post", $it['author-name']) : L10n::t("%s commented on %s's post", $it['author-name'], $it['pname'])); - $default_item_when = Temporal::convert($it['created'], date_default_timezone_get(), 'UTC', 'r'); + $default_item_when = Temporal::local($it['created'], 'r'); $default_item_ago = relative_date($it['created']); } diff --git a/src/Object/Post.php b/src/Object/Post.php index be3018cc9..4e83d2ff9 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -124,7 +124,7 @@ class Post extends BaseObject if (strtotime($item['edited']) - strtotime($item['created']) > 1) { $edited = [ 'label' => L10n::t('This entry was edited'), - 'date' => Temporal::convert($item['edited'], date_default_timezone_get(), 'UTC', 'r'), + 'date' => Temporal::local($item['edited'], 'r'), 'relative' => relative_date($item['edited']) ]; } @@ -364,7 +364,7 @@ class Post extends BaseObject 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, - 'localtime' => Temporal::convert($item['created'], date_default_timezone_get(), 'UTC', 'r'), + 'localtime' => Temporal::local($item['created'], 'r'), 'ago' => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']), 'app' => $item['app'], 'created' => relative_date($item['created']), diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 8deadd5e8..0e8c8f18c 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -135,6 +135,18 @@ class Temporal return self::convert($time, 'UTC', 'UTC', $format); } + /** + * convert() shorthand for local. + * + * @param string $time A date/time string + * @param string $format DateTime format string or Temporal constant + * @return string + */ + public static function local($time, $format = self::MYSQL) + { + return self::convert($time, date_default_timezone_get(), 'UTC', $format); + } + /** * convert() shorthand for timezoned now. * @@ -154,7 +166,7 @@ class Temporal */ public static function localNow($format = self::MYSQL) { - return self::convert('now', date_default_timezone_get(), 'UTC', $format); + return self::local('now', $format); } /** @@ -165,7 +177,7 @@ class Temporal */ public static function utcNow($format = self::MYSQL) { - return self::convert('now', 'UTC', 'UTC', $format); + return self::utc('now', $format); } /** From b7a735529212a1305bdfa74b874cef9789d01a2d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 19:41:40 -0500 Subject: [PATCH 15/24] Simplify include/bb2diaspora event format --- include/bb2diaspora.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5808e64ed..a7ebc4e0f 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -244,16 +244,14 @@ 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(Temporal::utc($ev['start'], $bd_format)) - : day_translate(Temporal::utc($ev['start'], $bd_format)) + $o .= L10n::t('Starts:') . ' ' . '[' . day_translate( + $ev['adjust'] ? Temporal::utc($ev['start'], $bd_format) : Temporal::utc($ev['start'], $bd_format) ) . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n"; if (! $ev['nofinish']) { - $o .= L10n::t('Finishes:') . ' ' . '[' - . (($ev['adjust']) ? day_translate(Temporal::utc($ev['finish'], $bd_format)) - : day_translate(Temporal::utc($ev['finish'], $bd_format)) + $o .= L10n::t('Finishes:') . ' ' . '[' . day_translate( + $ev['adjust'] ? Temporal::utc($ev['finish'], $bd_format) : Temporal::utc($ev['finish'], $bd_format) ) . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n"; } From 5e7285b9ba3236e3c5b6163df323eefebbc8b20e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Jan 2018 21:38:34 -0500 Subject: [PATCH 16/24] Move Temporal::convert() to DateTimeFormat::convert() --- boot.php | 8 +- include/api.php | 20 ++--- include/bb2diaspora.php | 10 +-- include/conversation.php | 4 +- include/dba.php | 6 +- include/enotify.php | 4 +- include/event.php | 66 +++++++------- include/items.php | 24 ++---- include/security.php | 6 +- include/text.php | 6 +- mod/admin.php | 4 +- mod/cal.php | 16 ++-- mod/contacts.php | 6 +- mod/dfrn_confirm.php | 14 +-- mod/dfrn_request.php | 10 +-- mod/events.php | 44 +++++----- mod/fsuggest.php | 4 +- mod/invite.php | 4 +- mod/item.php | 16 ++-- mod/localtime.php | 2 +- mod/lostpass.php | 6 +- mod/message.php | 6 +- mod/network.php | 12 +-- mod/photos.php | 18 ++-- mod/ping.php | 12 +-- mod/poco.php | 7 +- mod/profile.php | 8 +- mod/profile_photo.php | 6 +- mod/profiles.php | 12 +-- mod/proxy.php | 4 +- mod/pubsubhubbub.php | 4 +- mod/register.php | 4 +- mod/settings.php | 3 +- mod/videos.php | 6 +- mod/wall_attach.php | 4 +- src/Content/OEmbed.php | 4 +- src/Core/Cache.php | 20 ++--- src/Core/NotificationsManager.php | 10 +-- src/Core/Worker.php | 19 ++-- src/Database/DBM.php | 4 +- src/Model/Contact.php | 44 +++++----- src/Model/GContact.php | 12 +-- src/Model/Item.php | 3 +- src/Model/Mail.php | 10 +-- src/Model/Photo.php | 6 +- src/Model/Process.php | 4 +- src/Model/Profile.php | 28 +++--- src/Model/Queue.php | 13 ++- src/Model/User.php | 6 +- src/Module/Login.php | 10 +-- src/Network/FKOAuth1.php | 4 +- src/Object/Post.php | 8 +- src/Protocol/DFRN.php | 52 +++++------ src/Protocol/Diaspora.php | 71 ++++++++------- src/Protocol/OStatus.php | 18 ++-- src/Protocol/PortableContact.php | 42 ++++----- src/Util/DateTimeFormat.php | 139 ++++++++++++++++++++++++++++++ src/Util/ParseUrl.php | 2 +- src/Util/Temporal.php | 123 -------------------------- src/Worker/Cron.php | 18 ++-- src/Worker/CronHooks.php | 4 +- src/Worker/DiscoverPoCo.php | 4 +- src/Worker/OnePoll.php | 51 +++++------ src/Worker/UpdateGContact.php | 4 +- 64 files changed, 568 insertions(+), 551 deletions(-) create mode 100644 src/Util/DateTimeFormat.php diff --git a/boot.php b/boot.php index 66e4645e5..59ab52552 100644 --- a/boot.php +++ b/boot.php @@ -28,7 +28,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Database\DBStructure; use Friendica\Model\Contact; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; use Friendida\Core\L10n; require_once 'include/text.php'; @@ -1142,14 +1142,14 @@ function feed_birthday($uid, $tz) if (DBM::is_result($p)) { $tmp_dob = substr($p[0]['dob'], 5); if (intval($tmp_dob)) { - $y = Temporal::timezoneNow($tz, 'Y'); + $y = DateTimeFormat::timezoneNow($tz, 'Y'); $bd = $y . '-' . $tmp_dob . ' 00:00'; $t_dob = strtotime($bd); - $now = strtotime(Temporal::timezoneNow($tz)); + $now = strtotime(DateTimeFormat::timezoneNow($tz)); if ($t_dob < $now) { $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; } - $birthday = Temporal::convert($bd, 'UTC', $tz, Temporal::ATOM); + $birthday = DateTimeFormat::convert($bd, 'UTC', $tz, DateTimeFormat::ATOM); } } diff --git a/include/api.php b/include/api.php index c383c5565..96a935614 100644 --- a/include/api.php +++ b/include/api.php @@ -36,8 +36,8 @@ use Friendica\Network\HTTPException\TooManyRequestsException; use Friendica\Network\HTTPException\UnauthorizedException; use Friendica\Object\Image; use Friendica\Protocol\Diaspora; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; use Friendica\Util\XML; require_once 'include/bbcode.php'; @@ -111,7 +111,7 @@ function api_source() function api_date($str) { // Wed May 23 06:01:13 +0000 2007 - return Temporal::utc($str, "D M d H:i:s +0000 Y"); + return DateTimeFormat::utc($str, "D M d H:i:s +0000 Y"); } /** @@ -460,7 +460,7 @@ function api_rss_extra(App $a, $arr, $user_info) 'self' => System::baseUrl() . "/" . $a->query_string, 'base' => System::baseUrl(), 'updated' => api_date(null), - 'atom_updated' => Temporal::utcNow(Temporal::ATOM), + 'atom_updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM), 'language' => $user_info['language'], 'logo' => System::baseUrl() . "/images/friendica-32.png", ]; @@ -1162,7 +1162,7 @@ function api_statuses_update($type) // Check for throttling (maximum posts per day, week and month) $throttle_day = Config::get('system', 'throttle_limit_day'); if ($throttle_day > 0) { - $datefrom = date(Temporal::MYSQL, time() - 24*60*60); + $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60); $r = q( "SELECT COUNT(*) AS `posts_day` FROM `item` WHERE `uid`=%d AND `wall` @@ -1186,7 +1186,7 @@ function api_statuses_update($type) $throttle_week = Config::get('system', 'throttle_limit_week'); if ($throttle_week > 0) { - $datefrom = date(Temporal::MYSQL, time() - 24*60*60*7); + $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7); $r = q( "SELECT COUNT(*) AS `posts_week` FROM `item` WHERE `uid`=%d AND `wall` @@ -1210,7 +1210,7 @@ function api_statuses_update($type) $throttle_month = Config::get('system', 'throttle_limit_month'); if ($throttle_month > 0) { - $datefrom = date(Temporal::MYSQL, time() - 24*60*60*30); + $datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30); $r = q( "SELECT COUNT(*) AS `posts_month` FROM `item` WHERE `uid`=%d AND `wall` @@ -3207,7 +3207,7 @@ function api_account_rate_limit_status($type) '@attributes' => ["type" => "integer"], 'hourly-limit' => '150', '@attributes2' => ["type" => "integer"], - 'reset-time' => Temporal::utc('now + 1 hour', Temporal::ATOM), + 'reset-time' => DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM), '@attributes3' => ["type" => "datetime"], 'reset_time_in_seconds' => strtotime('now + 1 hour'), '@attributes4' => ["type" => "integer"], @@ -3217,7 +3217,7 @@ function api_account_rate_limit_status($type) 'reset_time_in_seconds' => strtotime('now + 1 hour'), 'remaining_hits' => '150', 'hourly_limit' => '150', - 'reset_time' => api_date(Temporal::utc('now + 1 hour', Temporal::ATOM)), + 'reset_time' => api_date(DateTimeFormat::utc('now + 1 hour', DateTimeFormat::ATOM)), ]; } @@ -4216,7 +4216,7 @@ function api_fr_photo_create_update($type) $result = q( "UPDATE `photo` SET %s, `edited`='%s' WHERE `uid` = %d AND `resource-id` = '%s' AND `album` = '%s'", $sql_extra, - Temporal::utcNow(), // update edited timestamp + DateTimeFormat::utcNow(), // update edited timestamp intval(api_user()), dbesc($photo_id), dbesc($album) @@ -4420,7 +4420,7 @@ function api_account_update_profile_image($type) q( "UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval(local_user()) ); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index a7ebc4e0f..0cb50e95e 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -7,7 +7,7 @@ use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Model\Contact; use Friendica\Network\Probe; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; use League\HTMLToMarkdown\HtmlConverter; require_once 'include/event.php'; @@ -245,15 +245,15 @@ function format_event_diaspora($ev) { // @todo What. Is. Going. On. With. This. Useless. Ternary. Operator? - mrpetovan $o .= L10n::t('Starts:') . ' ' . '[' . day_translate( - $ev['adjust'] ? Temporal::utc($ev['start'], $bd_format) : Temporal::utc($ev['start'], $bd_format) + $ev['adjust'] ? DateTimeFormat::utc($ev['start'], $bd_format) : DateTimeFormat::utc($ev['start'], $bd_format) ) - . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['start'])) . ")\n"; + . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['start'])) . ")\n"; if (! $ev['nofinish']) { $o .= L10n::t('Finishes:') . ' ' . '[' . day_translate( - $ev['adjust'] ? Temporal::utc($ev['finish'], $bd_format) : Temporal::utc($ev['finish'], $bd_format) + $ev['adjust'] ? DateTimeFormat::utc($ev['finish'], $bd_format) : DateTimeFormat::utc($ev['finish'], $bd_format) ) - . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(Temporal::utc($ev['finish'])) . ")\n"; + . '](' . System::baseUrl() . '/localtime/?f=&time=' . urlencode(DateTimeFormat::utc($ev['finish'])) . ")\n"; } if (strlen($ev['location'])) { diff --git a/include/conversation.php b/include/conversation.php index 98cb1773b..d312c2d9e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -17,7 +17,7 @@ use Friendica\Model\Profile; use Friendica\Object\Post; use Friendica\Util\XML; use Friendica\Object\Thread; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once "include/bbcode.php"; require_once "include/acl_selectors.php"; @@ -790,7 +790,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body_e), - 'localtime' => Temporal::local($item['created'], 'r'), + 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => (($item['app']) ? L10n::t('%s from %s', relative_date($item['created']),$item['app']) : relative_date($item['created'])), 'location' => $location_e, 'indent' => '', diff --git a/include/dba.php b/include/dba.php index 180748db9..f6bab9e3c 100644 --- a/include/dba.php +++ b/include/dba.php @@ -4,7 +4,7 @@ use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Database\DBStructure; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once('include/datetime.php'); @@ -190,7 +190,7 @@ class dba { if ($log) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log_index"], Temporal::utcNow()."\t". + @file_put_contents($a->config["system"]["db_log_index"], DateTimeFormat::utcNow()."\t". $row['key']."\t".$row['rows']."\t".$row['Extra']."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". @@ -495,7 +495,7 @@ class dba { $duration = round($duration, 3); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - @file_put_contents($a->config["system"]["db_log"], Temporal::utcNow()."\t".$duration."\t". + @file_put_contents($a->config["system"]["db_log"], DateTimeFormat::utcNow()."\t".$duration."\t". basename($backtrace[1]["file"])."\t". $backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t". substr(self::replace_parameters($sql, $args), 0, 2000)."\n", FILE_APPEND); diff --git a/include/enotify.php b/include/enotify.php index cf219676e..2b8c36e25 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -8,8 +8,8 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Emailer; -use Friendica\Util\Temporal; require_once 'include/bbcode.php'; require_once 'include/html2bbcode.php'; @@ -451,7 +451,7 @@ function notification($params) $datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['url'] = $params['source_link']; $datarray['photo'] = $params['source_photo']; - $datarray['date'] = Temporal::utcNow(); + $datarray['date'] = DateTimeFormat::utcNow(); $datarray['uid'] = $params['uid']; $datarray['link'] = $itemlink; $datarray['iid'] = $item_id; diff --git a/include/event.php b/include/event.php index 95be09cd7..647697e5a 100644 --- a/include/event.php +++ b/include/event.php @@ -12,8 +12,8 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Item; use Friendica\Model\Profile; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; -use Friendica\Util\Temporal; require_once 'include/bbcode.php'; require_once 'include/datetime.php'; @@ -28,14 +28,14 @@ function format_event_html($ev, $simple = false) { $event_start = day_translate( $ev['adjust'] ? - Temporal::local($ev['start'], $bd_format) - : Temporal::utc($ev['start'], $bd_format) + DateTimeFormat::local($ev['start'], $bd_format) + : DateTimeFormat::utc($ev['start'], $bd_format) ); $event_end = day_translate( $ev['adjust'] ? - Temporal::local($ev['finish'], $bd_format) - : Temporal::utc($ev['finish'], $bd_format) + DateTimeFormat::local($ev['finish'], $bd_format) + : DateTimeFormat::utc($ev['finish'], $bd_format) ); if ($simple) { @@ -61,13 +61,13 @@ function format_event_html($ev, $simple = false) { $o .= '
' . bbcode($ev['summary']) . '
' . "\r\n"; $o .= '
' . L10n::t('Starts:') . ' '.$event_start . '
' . "\r\n"; if (! $ev['nofinish']) { $o .= '
' . L10n::t('Finishes:') . ' '.$event_end . '
' . "\r\n"; } @@ -200,8 +200,8 @@ function sort_by_date($a) { function ev_compare($a,$b) { - $date_a = (($a['adjust']) ? Temporal::local($a['start']) : $a['start']); - $date_b = (($b['adjust']) ? Temporal::local($b['start']) : $b['start']); + $date_a = (($a['adjust']) ? DateTimeFormat::local($a['start']) : $a['start']); + $date_b = (($b['adjust']) ? DateTimeFormat::local($b['start']) : $b['start']); if ($date_a === $date_b) { return strcasecmp($a['desc'], $b['desc']); @@ -244,8 +244,8 @@ function event_store($arr) { $a = get_app(); - $arr['created'] = (($arr['created']) ? $arr['created'] : Temporal::utcNow()); - $arr['edited'] = (($arr['edited']) ? $arr['edited'] : Temporal::utcNow()); + $arr['created'] = (($arr['created']) ? $arr['created'] : DateTimeFormat::utcNow()); + $arr['edited'] = (($arr['edited']) ? $arr['edited'] : DateTimeFormat::utcNow()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['uri'] = (x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid'])); @@ -595,15 +595,15 @@ function process_events($arr) { $fmt = L10n::t('l, F j'); if (count($arr)) { foreach ($arr as $rr) { - $j = (($rr['adjust']) ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j')); - $d = (($rr['adjust']) ? Temporal::local($rr['start'], $fmt) : Temporal::utc($rr['start'], $fmt)); + $j = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j')); + $d = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], $fmt) : DateTimeFormat::utc($rr['start'], $fmt)); $d = day_translate($d); - $start = (($rr['adjust']) ? Temporal::local($rr['start'], 'c') : Temporal::utc($rr['start'], 'c')); + $start = (($rr['adjust']) ? DateTimeFormat::local($rr['start'], 'c') : DateTimeFormat::utc($rr['start'], 'c')); if ($rr['nofinish']) { $end = null; } else { - $end = (($rr['adjust']) ? Temporal::local($rr['finish'], 'c') : Temporal::utc($rr['finish'], 'c')); + $end = (($rr['adjust']) ? DateTimeFormat::local($rr['finish'], 'c') : DateTimeFormat::utc($rr['finish'], 'c')); } $is_first = ($d !== $last_date); @@ -930,27 +930,27 @@ function format_event_item($item) { // Convert the time to different formats. $dtstart_dt = day_translate( $item['event-adjust'] ? - Temporal::local($item['event-start'], $dformat) - : Temporal::utc($item['event-start'], $dformat) + DateTimeFormat::local($item['event-start'], $dformat) + : DateTimeFormat::utc($item['event-start'], $dformat) ); - $dtstart_title = Temporal::utc($item['event-start'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); + $dtstart_title = DateTimeFormat::utc($item['event-start'], $item['event-adjust'] ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s'); // Format: Jan till Dec. $month_short = day_short_translate( $item['event-adjust'] ? - Temporal::local($item['event-start'], 'M') - : Temporal::utc($item['event-start'], 'M') + DateTimeFormat::local($item['event-start'], 'M') + : DateTimeFormat::utc($item['event-start'], 'M') ); // Format: 1 till 31. $date_short = $item['event-adjust'] ? - Temporal::local($item['event-start'], 'j') - : Temporal::utc($item['event-start'], 'j'); + DateTimeFormat::local($item['event-start'], 'j') + : DateTimeFormat::utc($item['event-start'], 'j'); $start_time = $item['event-adjust'] ? - Temporal::local($item['event-start'], $tformat) - : Temporal::utc($item['event-start'], $tformat); + DateTimeFormat::local($item['event-start'], $tformat) + : DateTimeFormat::utc($item['event-start'], $tformat); $start_short = day_short_translate( $item['event-adjust'] ? - Temporal::local($item['event-start'], $dformat_short) - : Temporal::utc($item['event-start'], $dformat_short) + DateTimeFormat::local($item['event-start'], $dformat_short) + : DateTimeFormat::utc($item['event-start'], $dformat_short) ); // If the option 'nofinisch' isn't set, we need to format the finish date/time. @@ -958,18 +958,18 @@ function format_event_item($item) { $finish = true; $dtend_dt = day_translate( $item['event-adjust'] ? - Temporal::local($item['event-finish'], $dformat) - : Temporal::utc($item['event-finish'], $dformat) + DateTimeFormat::local($item['event-finish'], $dformat) + : DateTimeFormat::utc($item['event-finish'], $dformat) ); - $dtend_title = Temporal::utc($item['event-finish'], $item['event-adjust'] ? Temporal::ATOM : 'Y-m-d\TH:i:s'); + $dtend_title = DateTimeFormat::utc($item['event-finish'], $item['event-adjust'] ? DateTimeFormat::ATOM : 'Y-m-d\TH:i:s'); $end_short = day_short_translate( $item['event-adjust'] ? - Temporal::local($item['event-finish'], $dformat_short) - : Temporal::utc($item['event-finish'], $dformat_short) + DateTimeFormat::local($item['event-finish'], $dformat_short) + : DateTimeFormat::utc($item['event-finish'], $dformat_short) ); $end_time = $item['event-adjust'] ? - Temporal::local($item['event-finish'], $tformat) - : Temporal::utc($item['event-finish'], $tformat); + DateTimeFormat::local($item['event-finish'], $tformat) + : DateTimeFormat::utc($item['event-finish'], $tformat); // Check if start and finish time is at the same day. if (substr($dtstart_title, 0, 10) === substr($dtend_title, 0, 10)) { $same_date = true; diff --git a/include/items.php b/include/items.php index e5a04b120..f1c895f90 100644 --- a/include/items.php +++ b/include/items.php @@ -9,22 +9,14 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\System; -use Friendica\Core\Worker; use Friendica\Database\DBM; -use Friendica\Model\Contact; -use Friendica\Model\Conversation; -use Friendica\Model\GContact; -use Friendica\Model\Group; use Friendica\Model\Item; -use Friendica\Model\Term; -use Friendica\Model\User; -use Friendica\Object\Image; use Friendica\Protocol\DFRN; use Friendica\Protocol\Feed; -use Friendica\Util\Network; use Friendica\Protocol\OStatus; +use Friendica\Util\DateTimeFormat; +use Friendica\Util\Network; use Friendica\Util\ParseUrl; -use Friendica\Util\Temporal; require_once 'include/bbcode.php'; require_once 'include/tags.php'; @@ -416,7 +408,7 @@ function drop_item($id) { /* arrange the list in years */ function list_post_dates($uid, $wall) { - $dnow = Temporal::localNow('Y-m-d'); + $dnow = DateTimeFormat::localNow('Y-m-d'); $dthen = Item::firstPostDate($uid, $wall); if (!$dthen) { @@ -437,14 +429,14 @@ function list_post_dates($uid, $wall) { $dyear = intval(substr($dnow, 0, 4)); $dstart = substr($dnow, 0, 8) . '01'; $dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5))); - $start_month = Temporal::utc($dstart, 'Y-m-d'); - $end_month = Temporal::utc($dend, 'Y-m-d'); - $str = day_translate(Temporal::utc($dnow, 'F')); + $start_month = DateTimeFormat::utc($dstart, 'Y-m-d'); + $end_month = DateTimeFormat::utc($dend, 'Y-m-d'); + $str = day_translate(DateTimeFormat::utc($dnow, 'F')); if (!$ret[$dyear]) { $ret[$dyear] = []; } $ret[$dyear][] = [$str, $end_month, $start_month]; - $dnow = Temporal::utc($dnow . ' -1 month', 'Y-m-d'); + $dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d'); } return $ret; } @@ -474,7 +466,7 @@ function posted_date_widget($url, $uid, $wall) { return $o; } - $cutoff_year = intval(Temporal::localNow('Y')) - $visible_years; + $cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years; $cutoff = ((array_key_exists($cutoff_year, $ret))? true : false); $o = replace_macros(get_markup_template('posted_date_widget.tpl'),[ diff --git a/include/security.php b/include/security.php index e370e9340..45f8d86b1 100644 --- a/include/security.php +++ b/include/security.php @@ -10,7 +10,7 @@ use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Group; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; /** * @brief Calculate the hash that is needed for the "Friendica" cookie @@ -142,10 +142,10 @@ function authenticate_success($user_record, $login_initial = false, $interactive header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"'); if ($login_initial || $login_refresh) { - dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]); + dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]); // Set the login date for all identities of the user - dba::update('user', ['login_date' => Temporal::utcNow()], + dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]); } diff --git a/include/text.php b/include/text.php index 6a48d7ef8..73792e53c 100644 --- a/include/text.php +++ b/include/text.php @@ -15,8 +15,8 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Profile; use Friendica\Model\Term; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; -use Friendica\Util\Temporal; require_once "mod/proxy.php"; require_once "include/conversation.php"; @@ -723,7 +723,7 @@ function logger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", - Temporal::utcNow(Temporal::ATOM), + DateTimeFormat::utcNow(DateTimeFormat::ATOM), $process_id, $LOGGER_LEVELS[$level], basename($callers[0]['file']), @@ -789,7 +789,7 @@ function dlogger($msg, $level = 0) { $callers = debug_backtrace(); $logline = sprintf("%s@\t%s:\t%s:\t%s\t%s\t%s\n", - Temporal::utcNow(), + DateTimeFormat::utcNow(), $process_id, basename($callers[0]['file']), $callers[0]['line'], diff --git a/mod/admin.php b/mod/admin.php index 9bd94cd03..5d6a8fbaf 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -20,7 +20,7 @@ use Friendica\Model\Contact; use Friendica\Model\Item; use Friendica\Model\User; use Friendica\Module\Login; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/enotify.php'; require_once 'include/text.php'; @@ -740,7 +740,7 @@ function admin_page_summary(App $a) if (!$last_worker_call) { $showwarning = true; $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!'); - } elseif ((strtotime(Temporal::utcNow()) - strtotime($last_worker_call)) > 60 * 60) { + } elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) { $showwarning = true; $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call); } diff --git a/mod/cal.php b/mod/cal.php index 22005c06a..cafef3e30 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -17,7 +17,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Protocol\DFRN; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/event.php'; @@ -152,8 +152,8 @@ function cal_content(App $a) // The view mode part is similiar to /mod/events.php if ($mode == 'view') { - $thisyear = Temporal::localNow('Y'); - $thismonth = Temporal::localNow('m'); + $thisyear = DateTimeFormat::localNow('Y'); + $thismonth = DateTimeFormat::localNow('m'); if (!$y) { $y = intval($thisyear); } @@ -203,11 +203,11 @@ function cal_content(App $a) } } - $start = Temporal::utc($start); - $finish = Temporal::utc($finish); + $start = DateTimeFormat::utc($start); + $finish = DateTimeFormat::utc($finish); - $adjust_start = Temporal::local($start); - $adjust_finish = Temporal::local($finish); + $adjust_start = DateTimeFormat::local($start); + $adjust_finish = DateTimeFormat::local($finish); // put the event parametes in an array so we can better transmit them $event_params = [ @@ -231,7 +231,7 @@ function cal_content(App $a) if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); + $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'); if (!x($links, $j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } diff --git a/mod/contacts.php b/mod/contacts.php index 81f1a6caf..c37c4f3d5 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -17,7 +17,7 @@ use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Network\Probe; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'mod/proxy.php'; @@ -540,7 +540,7 @@ function contacts_content(App $a) $insecure = L10n::t('Private communications are not available for this contact.'); - $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::local($contact['last-update'], 'D, j M Y, g:i A')); + $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : DateTimeFormat::local($contact['last-update'], 'D, j M Y, g:i A')); if ($contact['last-update'] > NULL_DATE) { $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29")); @@ -554,7 +554,7 @@ function contacts_content(App $a) // tabs $tab_str = contacts_tab($a, $contact_id, 2); - $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < Temporal::utcNow()) ? L10n::t('Communications lost with this contact!') : ''); + $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : ''); $fetch_further_information = null; if ($contact['network'] == NETWORK_FEED) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 9a46d463b..d5264aa05 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -31,8 +31,8 @@ use Friendica\Model\User; use Friendica\Network\Probe; use Friendica\Protocol\Diaspora; use Friendica\Util\Crypto; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; use Friendica\Util\XML; require_once 'include/enotify.php'; @@ -327,8 +327,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($duplex), intval($hidden), dbesc(NETWORK_DFRN), @@ -378,8 +378,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `rel` = %d WHERE `id` = %d ", - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($addr), dbesc($notify), dbesc($poll), @@ -619,8 +619,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) `network` = '%s' WHERE `id` = %d ", intval($new_relation), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($duplex), intval($forum), intval($prv), diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 6db198dcd..34cc9cf25 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -24,8 +24,8 @@ use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Module\Login; use Friendica\Network\Probe; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; require_once 'include/enotify.php'; @@ -137,7 +137,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`, `blocked`, `pending`) VALUES ( %d, '%s', '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d)", intval(local_user()), - Temporal::utcNow(), + DateTimeFormat::utcNow(), dbesc($dfrn_url), dbesc(normalise_link($dfrn_url)), $parms['addr'], @@ -241,7 +241,7 @@ function dfrn_request_post(App $a) // Block friend request spam if ($maxreq) { $r = q("SELECT * FROM `intro` WHERE `datetime` > '%s' AND `uid` = %d", - dbesc(Temporal::utc('now - 24 hours')), + dbesc(DateTimeFormat::utc('now - 24 hours')), intval($uid) ); if (DBM::is_result($r) && count($r) > $maxreq) { @@ -382,7 +382,7 @@ function dfrn_request_post(App $a) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", intval($uid), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), $parms['url'], dbesc(normalise_link($url)), $parms['addr'], @@ -430,7 +430,7 @@ function dfrn_request_post(App $a) ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), dbesc(notags(trim($_POST['dfrn-request-message']))), dbesc($hash), - dbesc(Temporal::utcNow()) + dbesc(DateTimeFormat::utcNow()) ); } diff --git a/mod/events.php b/mod/events.php index 1d61dfcc3..7637486f8 100644 --- a/mod/events.php +++ b/mod/events.php @@ -12,7 +12,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Item; use Friendica\Model\Profile; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/bbcode.php'; require_once 'include/datetime.php'; @@ -76,14 +76,14 @@ function events_post(App $a) { } if ($adjust) { - $start = Temporal::convert($start, 'UTC', date_default_timezone_get()); + $start = DateTimeFormat::convert($start, 'UTC', date_default_timezone_get()); if (! $nofinish) { - $finish = Temporal::convert($finish, 'UTC', date_default_timezone_get()); + $finish = DateTimeFormat::convert($finish, 'UTC', date_default_timezone_get()); } } else { - $start = Temporal::utc($start); + $start = DateTimeFormat::utc($start); if (! $nofinish) { - $finish = Temporal::utc($finish); + $finish = DateTimeFormat::utc($finish); } } @@ -276,8 +276,8 @@ function events_content(App $a) { // The view mode part is similiar to /mod/cal.php if ($mode == 'view') { - $thisyear = Temporal::localNow('Y'); - $thismonth = Temporal::localNow('m'); + $thisyear = DateTimeFormat::localNow('Y'); + $thismonth = DateTimeFormat::localNow('m'); if (! $y) { $y = intval($thisyear); } @@ -323,11 +323,11 @@ function events_content(App $a) { } } - $start = Temporal::utc($start); - $finish = Temporal::utc($finish); + $start = DateTimeFormat::utc($start); + $finish = DateTimeFormat::utc($finish); - $adjust_start = Temporal::local($start); - $adjust_finish = Temporal::local($finish); + $adjust_start = DateTimeFormat::local($start); + $adjust_finish = DateTimeFormat::local($finish); // put the event parametes in an array so we can better transmit them $event_params = [ @@ -351,7 +351,7 @@ function events_content(App $a) { if (DBM::is_result($r)) { $r = sort_by_date($r); foreach ($r as $rr) { - $j = $rr['adjust'] ? Temporal::local($rr['start'], 'j') : Temporal::utc($rr['start'], 'j'); + $j = $rr['adjust'] ? DateTimeFormat::local($rr['start'], 'j') : DateTimeFormat::utc($rr['start'], 'j'); if (! x($links,$j)) { $links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j; } @@ -465,19 +465,19 @@ function events_content(App $a) { $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); } - $syear = Temporal::convert($sdt, $tz, 'UTC', 'Y'); - $smonth = Temporal::convert($sdt, $tz, 'UTC', 'm'); - $sday = Temporal::convert($sdt, $tz, 'UTC', 'd'); + $syear = DateTimeFormat::convert($sdt, $tz, 'UTC', 'Y'); + $smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm'); + $sday = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd'); - $shour = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'H') : 0); - $sminute = ((x($orig_event)) ? Temporal::convert($sdt, $tz, 'UTC', 'i') : 0); + $shour = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : 0); + $sminute = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : 0); - $fyear = Temporal::convert($fdt, $tz, 'UTC', 'Y'); - $fmonth = Temporal::convert($fdt, $tz, 'UTC', 'm'); - $fday = Temporal::convert($fdt, $tz, 'UTC', 'd'); + $fyear = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y'); + $fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm'); + $fday = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd'); - $fhour = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'H') : 0); - $fminute = ((x($orig_event)) ? Temporal::convert($fdt, $tz, 'UTC', 'i') : 0); + $fhour = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : 0); + $fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : 0); require_once 'include/acl_selectors.php' ; diff --git a/mod/fsuggest.php b/mod/fsuggest.php index ccd38217d..86878a529 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -7,7 +7,7 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\Worker; use Friendica\Database\DBM; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function fsuggest_post(App $a) { @@ -52,7 +52,7 @@ function fsuggest_post(App $a) dbesc($r[0]['request']), dbesc($r[0]['photo']), dbesc($hash), - dbesc(Temporal::utcNow()) + dbesc(DateTimeFormat::utcNow()) ); $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", dbesc($hash), diff --git a/mod/invite.php b/mod/invite.php index 8ecbbe6cd..d638b860b 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -12,7 +12,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Protocol\Email; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function invite_post(App $a) { @@ -62,7 +62,7 @@ function invite_post(App $a) $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", dbesc($code), - dbesc(Temporal::utcNow()) + dbesc(DateTimeFormat::utcNow()) ); if (! is_site_admin()) { diff --git a/mod/item.php b/mod/item.php index 1b0010281..ccf98667c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -28,8 +28,8 @@ use Friendica\Model\GContact; use Friendica\Model\Item; use Friendica\Protocol\Diaspora; use Friendica\Protocol\Email; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Emailer; -use Friendica\Util\Temporal; require_once 'include/enotify.php'; require_once 'include/tags.php'; @@ -601,11 +601,11 @@ function item_post(App $a) { $datarray['author-link'] = $author['url']; $datarray['author-avatar'] = $author['thumb']; $datarray['author-id'] = Contact::getIdForURL($datarray['author-link'], 0); - $datarray['created'] = Temporal::utcNow(); - $datarray['edited'] = Temporal::utcNow(); - $datarray['commented'] = Temporal::utcNow(); - $datarray['received'] = Temporal::utcNow(); - $datarray['changed'] = Temporal::utcNow(); + $datarray['created'] = DateTimeFormat::utcNow(); + $datarray['edited'] = DateTimeFormat::utcNow(); + $datarray['commented'] = DateTimeFormat::utcNow(); + $datarray['received'] = DateTimeFormat::utcNow(); + $datarray['changed'] = DateTimeFormat::utcNow(); $datarray['extid'] = $extid; $datarray['guid'] = $guid; $datarray['uri'] = $uri; @@ -709,8 +709,8 @@ function item_post(App $a) { 'file' => $datarray['file'], 'rendered-html' => $datarray['rendered-html'], 'rendered-hash' => $datarray['rendered-hash'], - 'edited' => Temporal::utcNow(), - 'changed' => Temporal::utcNow()]; + 'edited' => DateTimeFormat::utcNow(), + 'changed' => DateTimeFormat::utcNow()]; Item::update($fields, ['id' => $post_id]); diff --git a/mod/localtime.php b/mod/localtime.php index 29402b34e..4920962a7 100644 --- a/mod/localtime.php +++ b/mod/localtime.php @@ -20,7 +20,7 @@ function localtime_post(App $a) $bd_format = L10n::t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM if ($_POST['timezone']) { - $a->data['mod-localtime'] = Temporal::convert($t, $_POST['timezone'], 'UTC', $bd_format); + $a->data['mod-localtime'] = DateTimeFormat::convert($t, $_POST['timezone'], 'UTC', $bd_format); } } diff --git a/mod/lostpass.php b/mod/lostpass.php index e3bea9db2..75d29731b 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -8,7 +8,7 @@ use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\User; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'boot.php'; require_once 'include/datetime.php'; @@ -33,7 +33,7 @@ function lostpass_post(App $a) $fields = [ 'pwdreset' => $pwdreset_token, - 'pwdreset_time' => Temporal::utcNow() + 'pwdreset_time' => DateTimeFormat::utcNow() ]; $result = dba::update('user', $fields, ['uid' => $user['uid']]); if ($result) { @@ -92,7 +92,7 @@ function lostpass_content(App $a) } // Password reset requests expire in 60 minutes - if ($user['pwdreset_time'] < Temporal::utc('now - 1 hour')) { + if ($user['pwdreset_time'] < DateTimeFormat::utc('now - 1 hour')) { $fields = [ 'pwdreset' => null, 'pwdreset_time' => null diff --git a/mod/message.php b/mod/message.php index 5f1efe5ba..ec5669937 100644 --- a/mod/message.php +++ b/mod/message.php @@ -11,7 +11,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Mail; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/acl_selectors.php'; require_once 'include/conversation.php'; @@ -397,7 +397,7 @@ function message_content(App $a) 'body' => $body_e, 'delete' => L10n::t('Delete message'), 'to_name' => $to_name_e, - 'date' => Temporal::local($message['created'], 'D, d M Y - g:i A'), + 'date' => DateTimeFormat::local($message['created'], 'D, d M Y - g:i A'), 'ago' => relative_date($message['created']), ]; @@ -498,7 +498,7 @@ function render_messages(array $msg, $t) '$delete' => L10n::t('Delete conversation'), '$body' => $body_e, '$to_name' => $to_name_e, - '$date' => Temporal::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')), + '$date' => DateTimeFormat::local($rr['mailcreated'], L10n::t('D, d M Y - g:i A')), '$ago' => relative_date($rr['mailcreated']), '$seen' => $rr['mailseen'], '$count' => L10n::tt('%d message', '%d messages', $rr['count']), diff --git a/mod/network.php b/mod/network.php index 01b6413e6..c2f05fd8e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -19,7 +19,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Module\Login; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/conversation.php'; require_once 'include/items.php'; @@ -681,11 +681,11 @@ function networkThreadedView(App $a, $update = 0) if ($datequery) { $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", - dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get())))); + dbesc(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get())))); } if ($datequery2) { $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", - dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get())))); + dbesc(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get())))); } $sql_order = ''; @@ -790,8 +790,8 @@ function networkThreadedView(App $a, $update = 0) $top_limit = current($r)['order_date']; $bottom_limit = end($r)['order_date']; } else { - $top_limit = Temporal::utcNow(); - $bottom_limit = Temporal::utcNow(); + $top_limit = DateTimeFormat::utcNow(); + $bottom_limit = DateTimeFormat::utcNow(); } // When checking for updates we need to fetch from the newest date to the newest date before @@ -804,7 +804,7 @@ function networkThreadedView(App $a, $update = 0) $top_limit = $last_date; } elseif ($a->pager['page'] == 1) { // Highest possible top limit when we are on the first page - $top_limit = Temporal::utcNow(); + $top_limit = DateTimeFormat::utcNow(); } $items = dba::p("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM `item` diff --git a/mod/photos.php b/mod/photos.php index 49b68a345..8b3dbdc75 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -20,8 +20,8 @@ use Friendica\Model\Profile; use Friendica\Network\Probe; use Friendica\Object\Image; use Friendica\Protocol\DFRN; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; -use Friendica\Util\Temporal; require_once 'include/items.php'; require_once 'include/acl_selectors.php'; @@ -291,7 +291,7 @@ function photos_post(App $a) if (DBM::is_result($r)) { foreach ($r as $rr) { q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($rr['parent-uri']), intval($page_owner_uid) ); @@ -364,8 +364,8 @@ function photos_post(App $a) ); if (DBM::is_result($i)) { q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), dbesc($i[0]['uri']), intval($page_owner_uid) ); @@ -402,7 +402,7 @@ function photos_post(App $a) $resource_id = $a->argv[2]; if (!strlen($albname)) { - $albname = Temporal::localNow('Y'); + $albname = DateTimeFormat::localNow('Y'); } if (x($_POST,'rotate') !== false && @@ -649,8 +649,8 @@ function photos_post(App $a) $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($newtag), dbesc($newinform), - dbesc(Temporal::utcNow()), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($item_id), intval($page_owner_uid) ); @@ -738,7 +738,7 @@ function photos_post(App $a) if (strlen($newalbum)) { $album = $newalbum; } else { - $album = Temporal::localNow('Y'); + $album = DateTimeFormat::localNow('Y'); } } @@ -1361,7 +1361,7 @@ function photos_content(App $a) $photo = [ 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'title'=> L10n::t('View Full Size'), - 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . Temporal::utcNow('ymdhis'), + 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . DateTimeFormat::utcNow('ymdhis'), 'height' => $hires['height'], 'width' => $hires['width'], 'album' => $hires['album'], diff --git a/mod/ping.php b/mod/ping.php index 56d5fe290..3249624fb 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -14,7 +14,7 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; use Friendica\Model\Group; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; use Friendica\Util\XML; require_once 'include/datetime.php'; @@ -225,8 +225,8 @@ function ping_init(App $a) WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 ORDER BY `start` ASC ", intval(local_user()), - dbesc(Temporal::utc('now + 7 days')), - dbesc(Temporal::utcNow()) + dbesc(DateTimeFormat::utc('now + 7 days')), + dbesc(DateTimeFormat::utcNow()) ); if (DBM::is_result($ev)) { Cache::set($cachekey, $ev, CACHE_HOUR); @@ -237,7 +237,7 @@ function ping_init(App $a) $all_events = count($ev); if ($all_events) { - $str_now = Temporal::timezoneNow($a->timezone, 'Y-m-d'); + $str_now = DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d'); foreach ($ev as $x) { $bd = false; if ($x['type'] === 'birthday') { @@ -246,7 +246,7 @@ function ping_init(App $a) } else { $events ++; } - if (Temporal::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { + if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { $all_events_today ++; if ($bd) { $birthdays_today ++; @@ -362,7 +362,7 @@ function ping_init(App $a) $notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO); } - $local_time = Temporal::local($notif['date']); + $local_time = DateTimeFormat::local($notif['date']); $notifications[] = [ 'id' => $notif['id'], diff --git a/mod/poco.php b/mod/poco.php index 1415ee9aa..639ab8469 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -3,13 +3,14 @@ // See here for a documentation for portable contacts: // https://web.archive.org/web/20160405005550/http://portablecontacts.net/draft-spec.html + use Friendica\App; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Protocol\PortableContact; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function poco_init(App $a) { $system_mode = false; @@ -44,7 +45,7 @@ function poco_init(App $a) { if ($a->argc > 1 && $a->argv[1] === '@global') { // List of all profiles that this server recently had data from $global = true; - $update_limit = date(Temporal::MYSQL, time() - 30 * 86400); + $update_limit = date(DateTimeFormat::MYSQL, time() - 30 * 86400); } if ($a->argc > 2 && $a->argv[2] === '@me') { $justme = true; @@ -81,7 +82,7 @@ function poco_init(App $a) { $sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid)); } if (x($_GET, 'updatedSince')) { - $update_limit = date(Temporal::MYSQL, strtotime($_GET['updatedSince'])); + $update_limit = date(DateTimeFormat::MYSQL, strtotime($_GET['updatedSince'])); } if ($global) { $contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')", diff --git a/mod/profile.php b/mod/profile.php index a10c22e94..a2fff27e0 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -16,7 +16,7 @@ use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Module\Login; use Friendica\Protocol\DFRN; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function profile_init(App $a) { @@ -236,7 +236,7 @@ function profile_content(App $a, $update = 0) if ($is_owner || !$last_updated) { $sql_extra4 = " AND `item`.`unseen`"; } else { - $gmupdate = gmdate(Temporal::MYSQL, $last_updated); + $gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated); $sql_extra4 = " AND `item`.`received` > '" . $gmupdate . "'"; } @@ -272,10 +272,10 @@ function profile_content(App $a, $update = 0) } if ($datequery) { - $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(Temporal::convert($datequery, 'UTC', date_default_timezone_get())))); + $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(DateTimeFormat::convert($datequery, 'UTC', date_default_timezone_get())))); } if ($datequery2) { - $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(Temporal::convert($datequery2, 'UTC', date_default_timezone_get())))); + $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(DateTimeFormat::convert($datequery2, 'UTC', date_default_timezone_get())))); } // Belongs the profile page to a forum? diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 82050e962..370e19ce5 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -12,7 +12,7 @@ use Friendica\Database\DBM; use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Object\Image; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function profile_photo_init(App $a) { @@ -130,7 +130,7 @@ function profile_photo_post(App $a) { // so that browsers will do a cache update unconditionally $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval(local_user()) ); @@ -230,7 +230,7 @@ function profile_photo_content(App $a) { ); $r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d", - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval(local_user()) ); diff --git a/mod/profiles.php b/mod/profiles.php index 25ce15ce8..bde24764f 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -18,7 +18,7 @@ use Friendica\Model\GContact; use Friendica\Model\Profile; use Friendica\Model\Item; use Friendica\Network\Probe; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; function profiles_init(App $a) { @@ -220,9 +220,9 @@ function profiles_post(App $a) { } if ($ignore_year) { - $dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d'); + $dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d'); } else { - $dob = Temporal::utc($dob, 'Y-m-d'); + $dob = DateTimeFormat::utc($dob, 'Y-m-d'); } } @@ -253,7 +253,7 @@ function profiles_post(App $a) { if (! strlen($howlong)) { $howlong = NULL_DATE; } else { - $howlong = Temporal::convert($howlong, 'UTC', date_default_timezone_get()); + $howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get()); } // linkify the relationship target if applicable @@ -488,7 +488,7 @@ function profiles_post(App $a) { if ($namechanged && $is_default) { $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d", dbesc($name), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval(local_user()) ); $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d", @@ -725,7 +725,7 @@ function profiles_content(App $a) { '$gender' => ContactSelector::gender($r[0]['gender']), '$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')], - '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::local($r[0]['howlong']))], + '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : DateTimeFormat::local($r[0]['howlong']))], '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']), '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']], '$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")], diff --git a/mod/proxy.php b/mod/proxy.php index 332b5bd1b..0b84233e5 100644 --- a/mod/proxy.php +++ b/mod/proxy.php @@ -10,8 +10,8 @@ use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Photo; use Friendica\Object\Image; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; define('PROXY_DEFAULT_TIME', 86400); // 1 Day @@ -188,7 +188,7 @@ function proxy_init(App $a) { die(); } - $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => Temporal::utcNow(), 'edited' => Temporal::utcNow(), + $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => DateTimeFormat::utcNow(), 'edited' => DateTimeFormat::utcNow(), 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime]; diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php index 4dc163cba..051ae2e84 100644 --- a/mod/pubsubhubbub.php +++ b/mod/pubsubhubbub.php @@ -4,8 +4,8 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use Friendica\Util\Temporal; function post_var($name) { return (x($_POST, $name)) ? notags(trim($_POST[$name])) : ''; @@ -139,7 +139,7 @@ function pubsubhubbub_init(App $a) { dbesc($hub_callback)); if ($subscribe) { - $last_update = Temporal::utcNow(); + $last_update = DateTimeFormat::utcNow(); $push_flag = 0; // if we are just updating an old subscription, keep the diff --git a/mod/register.php b/mod/register.php index 07a20e318..bf87c9259 100644 --- a/mod/register.php +++ b/mod/register.php @@ -11,7 +11,7 @@ use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Model\User; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/enotify.php'; require_once 'include/bbcode.php'; @@ -118,7 +118,7 @@ function register_post(App $a) $hash = random_string(); $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ", dbesc($hash), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval($user['uid']), dbesc($result['password']), dbesc($lang), diff --git a/mod/settings.php b/mod/settings.php index 5c220cb35..9aa2c0b5b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -17,6 +17,7 @@ use Friendica\Model\GContact; use Friendica\Model\Group; use Friendica\Model\User; use Friendica\Protocol\Email; +use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; use Friendica\Util\Temporal; @@ -631,7 +632,7 @@ function settings_post(App $a) if ($name_change) { q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`", dbesc($username), - dbesc(Temporal::utcNow()), + dbesc(DateTimeFormat::utcNow()), intval(local_user()) ); } diff --git a/mod/videos.php b/mod/videos.php index 66ca2979f..69adf1091 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -14,7 +14,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Profile; use Friendica\Protocol\DFRN; -use Friendica\Util\Temporal; +use Friendica\Util\DateTimeFormat; require_once 'include/items.php'; require_once 'include/acl_selectors.php'; @@ -170,8 +170,8 @@ function videos_post(App $a) { //echo "
"; var_dump($i); killme();
 			if (DBM::is_result($i)) {
 				q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
-					dbesc(Temporal::utcNow()),
-					dbesc(Temporal::utcNow()),
+					dbesc(DateTimeFormat::utcNow()),
+					dbesc(DateTimeFormat::utcNow()),
 					dbesc($i[0]['uri']),
 					intval(local_user())
 				);
diff --git a/mod/wall_attach.php b/mod/wall_attach.php
index 8cdee398e..30bc9641f 100644
--- a/mod/wall_attach.php
+++ b/mod/wall_attach.php
@@ -7,8 +7,8 @@ use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Database\DBM;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Mimetype;
-use Friendica\Util\Temporal;
 
 require_once 'include/datetime.php';
 
@@ -124,7 +124,7 @@ function wall_attach_post(App $a) {
 	$filedata = @file_get_contents($src);
 	$mimetype = Mimetype::getContentType($filename);
 	$hash = get_guid(64);
-	$created = Temporal::utcNow();
+	$created = DateTimeFormat::utcNow();
 
 	$fields = ['uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
 		'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,
diff --git a/src/Content/OEmbed.php b/src/Content/OEmbed.php
index 2a9db6488..b09fd2249 100644
--- a/src/Content/OEmbed.php
+++ b/src/Content/OEmbed.php
@@ -11,9 +11,9 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
-use Friendica\Util\Temporal;
 use dba;
 use DOMDocument;
 use DOMNode;
@@ -113,7 +113,7 @@ class OEmbed
 						'url' => normalise_link($embedurl),
 						'maxwidth' => $a->videowidth,
 						'content' => $txt,
-						'created' => Temporal::utcNow()
+						'created' => DateTimeFormat::utcNow()
 					], true);
 				}
 
diff --git a/src/Core/Cache.php b/src/Core/Cache.php
index d6eeb4822..36db52b0e 100644
--- a/src/Core/Cache.php
+++ b/src/Core/Cache.php
@@ -6,7 +6,7 @@ namespace Friendica\Core;
 
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 use Memcache;
 
@@ -147,7 +147,7 @@ class Cache
 			$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
 			return;
 		}
-		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => Temporal::utcNow()];
+		$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => DateTimeFormat::utcNow()];
 		$condition = ['k' => $key];
 		dba::update('cache', $fields, $condition, true);
 	}
@@ -165,21 +165,21 @@ class Cache
 		if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
 			if ($max_level == CACHE_MONTH) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						Temporal::utc("now - 30 days"),
+						DateTimeFormat::utc("now - 30 days"),
 						CACHE_MONTH];
 				dba::delete('cache', $condition);
 			}
 
 			if ($max_level <= CACHE_WEEK) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						Temporal::utc("now - 7 days"),
+						DateTimeFormat::utc("now - 7 days"),
 						CACHE_WEEK];
 				dba::delete('cache', $condition);
 			}
 
 			if ($max_level <= CACHE_DAY) {
 				$condition = ["`updated` < ? AND `expire_mode` = ?",
-						Temporal::utc("now - 1 days"),
+						DateTimeFormat::utc("now - 1 days"),
 						CACHE_DAY];
 				dba::delete('cache', $condition);
 			}
@@ -188,7 +188,7 @@ class Cache
 
 		if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					Temporal::utc("now - 1 hours"),
+					DateTimeFormat::utc("now - 1 hours"),
 					CACHE_HOUR];
 			dba::delete('cache', $condition);
 
@@ -197,7 +197,7 @@ class Cache
 
 		if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					Temporal::utc("now - 30 minutes"),
+					DateTimeFormat::utc("now - 30 minutes"),
 					CACHE_HALF_HOUR];
 			dba::delete('cache', $condition);
 
@@ -206,7 +206,7 @@ class Cache
 
 		if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					Temporal::utc("now - 15 minutes"),
+					DateTimeFormat::utc("now - 15 minutes"),
 					CACHE_QUARTER_HOUR];
 			dba::delete('cache', $condition);
 
@@ -215,7 +215,7 @@ class Cache
 
 		if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					Temporal::utc("now - 5 minutes"),
+					DateTimeFormat::utc("now - 5 minutes"),
 					CACHE_FIVE_MINUTES];
 			dba::delete('cache', $condition);
 
@@ -224,7 +224,7 @@ class Cache
 
 		if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
 			$condition = ["`updated` < ? AND `expire_mode` = ?",
-					Temporal::utc("now - 1 minutes"),
+					DateTimeFormat::utc("now - 1 minutes"),
 					CACHE_MINUTE];
 			dba::delete('cache', $condition);
 
diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php
index a28dfbb06..356ed4a47 100644
--- a/src/Core/NotificationsManager.php
+++ b/src/Core/NotificationsManager.php
@@ -13,8 +13,8 @@ use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\XML;
-use Friendica\Util\Temporal;
 
 require_once 'include/dba.php';
 require_once 'include/html2plain.php';
@@ -43,7 +43,7 @@ class NotificationsManager extends BaseObject
 	{
 		$rets = [];
 		foreach ($notes as $n) {
-			$local_time = Temporal::local($n['date']);
+			$local_time = DateTimeFormat::local($n['date']);
 			$n['timestamp'] = strtotime($local_time);
 			$n['date_rel'] = relative_date($n['date']);
 			$n['msg_html'] = bbcode($n['msg'], false, false, false, false);
@@ -244,7 +244,7 @@ class NotificationsManager extends BaseObject
 						$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
 						$default_item_url = $it['url'];
 						$default_item_text = strip_tags(bbcode($it['msg']));
-						$default_item_when = Temporal::local($it['date'], 'r');
+						$default_item_when = DateTimeFormat::local($it['date'], 'r');
 						$default_item_ago = relative_date($it['date']);
 						break;
 
@@ -254,7 +254,7 @@ class NotificationsManager extends BaseObject
 						$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
 						$default_item_url = $it['author-link'];
 						$default_item_text = L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']);
-						$default_item_when = Temporal::local($it['created'], 'r');
+						$default_item_when = DateTimeFormat::local($it['created'], 'r');
 						$default_item_ago = relative_date($it['created']);
 						break;
 
@@ -266,7 +266,7 @@ class NotificationsManager extends BaseObject
 						$default_item_text = (($it['id'] == $it['parent'])
 									? L10n::t("%s created a new post", $it['author-name'])
 									: L10n::t("%s commented on %s's post", $it['author-name'], $it['pname']));
-						$default_item_when = Temporal::local($it['created'], 'r');
+						$default_item_when = DateTimeFormat::local($it['created'], 'r');
 						$default_item_ago = relative_date($it['created']);
 				}
 
diff --git a/src/Core/Worker.php b/src/Core/Worker.php
index 8ea41c2ef..fd5a0bf4c 100644
--- a/src/Core/Worker.php
+++ b/src/Core/Worker.php
@@ -9,10 +9,9 @@ use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Process;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Lock;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
-
 use dba;
 
 require_once 'include/dba.php';
@@ -235,7 +234,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -245,7 +244,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', Temporal::utcNow());
+				Config::set('system', 'last_poller_execution', DateTimeFormat::utcNow());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 
@@ -278,7 +277,7 @@ class Worker
 
 			if ($age > 1) {
 				$stamp = (float)microtime(true);
-				dba::update('workerqueue', ['executed' => Temporal::utcNow()], ['pid' => $mypid, 'done' => false]);
+				dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
 				self::$db_duration += (microtime(true) - $stamp);
 			}
 
@@ -286,7 +285,7 @@ class Worker
 
 			$stamp = (float)microtime(true);
 			if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
-				Config::set('system', 'last_poller_execution', Temporal::utcNow());
+				Config::set('system', 'last_poller_execution', DateTimeFormat::utcNow());
 			}
 			self::$db_duration = (microtime(true) - $stamp);
 		} else {
@@ -574,7 +573,7 @@ class Worker
 					}
 					dba::update(
 						'workerqueue',
-						['executed' => NULL_DATE, 'created' => Temporal::utcNow(), 'priority' => $new_priority, 'pid' => 0],
+						['executed' => NULL_DATE, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
 						['id' => $entry["id"]]
 					);
 				} else {
@@ -825,7 +824,7 @@ class Worker
 		if ($found) {
 			$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
 			array_unshift($ids, $condition);
-			dba::update('workerqueue', ['executed' => Temporal::utcNow(), 'pid' => $mypid], $ids);
+			dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow(), 'pid' => $mypid], $ids);
 		}
 
 		return $found;
@@ -953,7 +952,7 @@ class Worker
 
 		/// @todo We should clean up the corresponding workerqueue entries as well
 		$condition = ["`created` < ? AND `command` = 'worker.php'",
-				Temporal::utc("now - ".$timeout." minutes")];
+				DateTimeFormat::utc("now - ".$timeout." minutes")];
 		dba::delete('process', $condition);
 	}
 
@@ -1040,7 +1039,7 @@ class Worker
 
 		$priority = PRIORITY_MEDIUM;
 		$dont_fork = Config::get("system", "worker_dont_fork");
-		$created = Temporal::utcNow();
+		$created = DateTimeFormat::utcNow();
 
 		if (is_int($run_parameter)) {
 			$priority = $run_parameter;
diff --git a/src/Database/DBM.php b/src/Database/DBM.php
index 463d3a325..6f14c12b8 100644
--- a/src/Database/DBM.php
+++ b/src/Database/DBM.php
@@ -5,7 +5,7 @@
 namespace Friendica\Database;
 
 use dba;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 
 require_once 'include/dba.php';
 
@@ -127,6 +127,6 @@ class DBM
 			$timestamp = -62135596800;
 		}
 
-		return date(Temporal::MYSQL, (int)$timestamp);
+		return date(DateTimeFormat::MYSQL, (int)$timestamp);
 	}
 }
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 212da3334..e57bcd99d 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -20,8 +20,8 @@ use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\PortableContact;
 use Friendica\Protocol\Salmon;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 
 require_once 'boot.php';
@@ -112,7 +112,7 @@ class Contact extends BaseObject
 
 		$return = dba::insert('contact', [
 			'uid'         => $user['uid'],
-			'created'     => Temporal::utcNow(),
+			'created'     => DateTimeFormat::utcNow(),
 			'self'        => 1,
 			'name'        => $user['username'],
 			'nick'        => $user['nickname'],
@@ -129,9 +129,9 @@ class Contact extends BaseObject
 			'poll'        => System::baseUrl() . '/dfrn_poll/'    . $user['nickname'],
 			'confirm'     => System::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
 			'poco'        => System::baseUrl() . '/poco/'         . $user['nickname'],
-			'name-date'   => Temporal::utcNow(),
-			'uri-date'    => Temporal::utcNow(),
-			'avatar-date' => Temporal::utcNow(),
+			'name-date'   => DateTimeFormat::utcNow(),
+			'uri-date'    => DateTimeFormat::utcNow(),
+			'avatar-date' => DateTimeFormat::utcNow(),
 			'closeness'   => 0
 		]);
 
@@ -210,10 +210,10 @@ class Contact extends BaseObject
 		}
 
 		if ($contact['term-date'] <= NULL_DATE) {
-			dba::update('contact', ['term-date' => Temporal::utcNow()], ['id' => $contact['id']]);
+			dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 
 			if ($contact['url'] != '') {
-				dba::update('contact', ['term-date' => Temporal::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
+				dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
 			}
 		} else {
 			/* @todo
@@ -224,7 +224,7 @@ class Contact extends BaseObject
 
 			/// @todo Check for contact vitality via probing
 			$expiry = $contact['term-date'] . ' + 32 days ';
-			if (Temporal::utcNow() > Temporal::utc($expiry)) {
+			if (DateTimeFormat::utcNow() > DateTimeFormat::utc($expiry)) {
 				/* Relationship is really truly dead. archive them rather than
 				 * delete, though if the owner tries to unarchive them we'll start
 				 * the whole process over again.
@@ -688,7 +688,7 @@ class Contact extends BaseObject
 			$contact_id = $contact["id"];
 
 			// Update the contact every 7 days
-			$update_contact = ($contact['avatar-date'] < Temporal::utc('now -7 days'));
+			$update_contact = ($contact['avatar-date'] < DateTimeFormat::utc('now -7 days'));
 
 			// We force the update if the avatar is empty
 			if (!x($contact, 'avatar')) {
@@ -728,7 +728,7 @@ class Contact extends BaseObject
 		if (!$contact_id) {
 			dba::insert('contact', [
 				'uid'       => $uid,
-				'created'   => Temporal::utcNow(),
+				'created'   => DateTimeFormat::utcNow(),
 				'url'       => $data["url"],
 				'nurl'      => normalise_link($data["url"]),
 				'addr'      => $data["addr"],
@@ -749,9 +749,9 @@ class Contact extends BaseObject
 				'request'   => $data["request"],
 				'confirm'   => $data["confirm"],
 				'poco'      => $data["poco"],
-				'name-date' => Temporal::utcNow(),
-				'uri-date'  => Temporal::utcNow(),
-				'avatar-date' => Temporal::utcNow(),
+				'name-date' => DateTimeFormat::utcNow(),
+				'uri-date'  => DateTimeFormat::utcNow(),
+				'avatar-date' => DateTimeFormat::utcNow(),
 				'writable'  => 1,
 				'blocked'   => 0,
 				'readonly'  => 0,
@@ -823,13 +823,13 @@ class Contact extends BaseObject
 		}
 
 		if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) {
-			$updated['uri-date'] = Temporal::utcNow();
+			$updated['uri-date'] = DateTimeFormat::utcNow();
 		}
 		if (($data["name"] != $contact["name"]) || ($data["nick"] != $contact["nick"])) {
-			$updated['name-date'] = Temporal::utcNow();
+			$updated['name-date'] = DateTimeFormat::utcNow();
 		}
 
-		$updated['avatar-date'] = Temporal::utcNow();
+		$updated['avatar-date'] = DateTimeFormat::utcNow();
 
 		dba::update('contact', $updated, ['id' => $contact_id], $contact);
 
@@ -1026,7 +1026,7 @@ class Contact extends BaseObject
 			if ($photos) {
 				dba::update(
 					'contact',
-					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => Temporal::utcNow()],
+					['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()],
 					['id' => $cid]
 				);
 
@@ -1261,7 +1261,7 @@ class Contact extends BaseObject
 			// create contact record
 			dba::insert('contact', [
 				'uid'     => $uid,
-				'created' => Temporal::utcNow(),
+				'created' => DateTimeFormat::utcNow(),
 				'url'     => $ret['url'],
 				'nurl'    => normalise_link($ret['url']),
 				'addr'    => $ret['addr'],
@@ -1485,7 +1485,7 @@ class Contact extends BaseObject
 			foreach ($r as $rr) {
 				logger('update_contact_birthday: ' . $rr['bd']);
 
-				$nextbd = Temporal::utcNow('Y') . substr($rr['bd'], 4);
+				$nextbd = DateTimeFormat::utcNow('Y') . substr($rr['bd'], 4);
 
 				/*
 				 * Add new birthday event for this person
@@ -1497,7 +1497,7 @@ class Contact extends BaseObject
 
 				// Check for duplicates
 				$s = q("SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
-					intval($rr['uid']), intval($rr['id']), dbesc(Temporal::utc($nextbd)), dbesc('birthday'));
+					intval($rr['uid']), intval($rr['id']), dbesc(DateTimeFormat::utc($nextbd)), dbesc('birthday'));
 
 				if (DBM::is_result($s)) {
 					continue;
@@ -1508,8 +1508,8 @@ class Contact extends BaseObject
 
 				q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`,`adjust`)
 				VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d' ) ", intval($rr['uid']), intval($rr['id']),
-					dbesc(Temporal::utcNow()), dbesc(Temporal::utcNow()), dbesc(Temporal::utc($nextbd)),
-					dbesc(Temporal::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
+					dbesc(DateTimeFormat::utcNow()), dbesc(DateTimeFormat::utcNow()), dbesc(DateTimeFormat::utc($nextbd)),
+					dbesc(DateTimeFormat::utc($nextbd . ' + 1 day ')), dbesc($bdtext), dbesc($bdtext2), dbesc('birthday'),
 					intval(0)
 				);
 
diff --git a/src/Model/GContact.php b/src/Model/GContact.php
index f588ec62b..5e75ba5a5 100644
--- a/src/Model/GContact.php
+++ b/src/Model/GContact.php
@@ -14,8 +14,8 @@ use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 use Exception;
 
@@ -120,12 +120,12 @@ class GContact
 				intval($uid),
 				intval($gcid),
 				intval($zcid),
-				dbesc(Temporal::utcNow())
+				dbesc(DateTimeFormat::utcNow())
 			);
 		} else {
 			q(
 				"UPDATE `glink` SET `updated` = '%s' WHERE `cid` = %d AND `uid` = %d AND `gcid` = %d AND `zcid` = %d",
-				dbesc(Temporal::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
 				intval($cid),
 				intval($uid),
 				intval($gcid),
@@ -717,8 +717,8 @@ class GContact
 				dbesc($contact["url"]),
 				dbesc(normalise_link($contact["url"])),
 				dbesc($contact["photo"]),
-				dbesc(Temporal::utcNow()),
-				dbesc(Temporal::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
 				dbesc($contact["location"]),
 				dbesc($contact["about"]),
 				intval($contact["hide"]),
@@ -1050,7 +1050,7 @@ class GContact
 
 		foreach ($r as $server) {
 			self::fetchGsUsers($server["url"]);
-			q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(Temporal::utcNow()), dbesc($server["nurl"]));
+			q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(DateTimeFormat::utcNow()), dbesc($server["nurl"]));
 		}
 	}
 
diff --git a/src/Model/Item.php b/src/Model/Item.php
index 62f19aeb5..818c4085f 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -22,6 +22,7 @@ use Friendica\Model\Term;
 use Friendica\Object\Image;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 use dba;
 use Text_LanguageDetect;
@@ -149,7 +150,7 @@ class Item extends BaseObject
 
 		// Set the item to "deleted"
 		dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
-					'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
+					'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
 				['id' => $item['id']]);
 
 		create_tags_from_item($item['id']);
diff --git a/src/Model/Mail.php b/src/Model/Mail.php
index 41981fe9e..f9b4c4d6d 100644
--- a/src/Model/Mail.php
+++ b/src/Model/Mail.php
@@ -10,7 +10,7 @@ use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Network\Probe;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -82,7 +82,7 @@ class Mail
 			$handles = $recip_handle . ';' . $sender_handle;
 
 			$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
-				'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
+				'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
 				'subject' => $subject, 'recips' => $handles];
 			if (dba::insert('conv', $fields)) {
 				$convid = dba::lastInsertId();
@@ -116,7 +116,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => Temporal::utcNow()
+				'created' => DateTimeFormat::utcNow()
 			]
 		);
 
@@ -196,7 +196,7 @@ class Mail
 
 		$convid = null;
 		$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
-			'created' => Temporal::utcNow(), 'updated' => Temporal::utcNow(),
+			'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
 			'subject' => $subject, 'recips' => $handles];
 		if (dba::insert('conv', $fields)) {
 			$convid = dba::lastInsertId();
@@ -224,7 +224,7 @@ class Mail
 				'replied' => 0,
 				'uri' => $uri,
 				'parent-uri' => $replyto,
-				'created' => Temporal::utcNow(),
+				'created' => DateTimeFormat::utcNow(),
 				'unknown' => 1
 			]
 		);
diff --git a/src/Model/Photo.php b/src/Model/Photo.php
index a736c3638..cf31849c8 100644
--- a/src/Model/Photo.php
+++ b/src/Model/Photo.php
@@ -12,8 +12,8 @@ use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Object\Image;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -55,8 +55,8 @@ class Photo
 			'contact-id' => $cid,
 			'guid' => $guid,
 			'resource-id' => $rid,
-			'created' => Temporal::utcNow(),
-			'edited' => Temporal::utcNow(),
+			'created' => DateTimeFormat::utcNow(),
+			'edited' => DateTimeFormat::utcNow(),
 			'filename' => basename($filename),
 			'type' => $Image->getType(),
 			'album' => $album,
diff --git a/src/Model/Process.php b/src/Model/Process.php
index 5cb3369c6..c360a13d0 100644
--- a/src/Model/Process.php
+++ b/src/Model/Process.php
@@ -5,7 +5,7 @@
 namespace Friendica\Model;
 
 use Friendica\BaseObject;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -34,7 +34,7 @@ class Process extends BaseObject
 		dba::transaction();
 
 		if (!dba::exists('process', ['pid' => $pid])) {
-			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => Temporal::utcNow()]);
+			$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
 		}
 
 		dba::commit();
diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index aeb7155f1..0dce1c08c 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -17,8 +17,8 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Protocol\Diaspora;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 
 require_once 'include/dba.php';
@@ -556,8 +556,8 @@ class Profile
 				WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
 				ORDER BY `start` ASC ",
 				local_user(),
-				Temporal::utc('now + 6 days'),
-				Temporal::utcNow()
+				DateTimeFormat::utc('now + 6 days'),
+				DateTimeFormat::utcNow()
 			);
 			if (DBM::is_result($s)) {
 				$r = dba::inArray($s);
@@ -600,7 +600,7 @@ class Profile
 
 					$rr['link'] = $url;
 					$rr['title'] = $rr['name'];
-					$rr['date'] = day_translate(Temporal::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
+					$rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
 					$rr['startime'] = null;
 					$rr['today'] = $today;
 				}
@@ -644,8 +644,8 @@ class Profile
 			WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
 			ORDER BY `start` ASC ",
 			local_user(),
-			Temporal::utc('now + 7 days'),
-			Temporal::utc('now - 1 days')
+			DateTimeFormat::utc('now + 7 days'),
+			DateTimeFormat::utc('now - 1 days')
 		);
 
 		$r = [];
@@ -658,8 +658,8 @@ class Profile
 					$total ++;
 				}
 
-				$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
-				if ($strt === Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
+				$strt = DateTimeFormat::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
+				if ($strt === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
 					$istoday = true;
 				}
 
@@ -674,17 +674,17 @@ class Profile
 					$description = L10n::t('[No description]');
 				}
 
-				$strt = Temporal::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
+				$strt = DateTimeFormat::convert($rr['start'], $rr['convert'] ? $a->timezone : 'UTC');
 
-				if (substr($strt, 0, 10) < Temporal::timezoneNow($a->timezone, 'Y-m-d')) {
+				if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
 					continue;
 				}
 
-				$today = ((substr($strt, 0, 10) === Temporal::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
+				$today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
 
 				$rr['title'] = $title;
 				$rr['description'] = $description;
-				$rr['date'] = day_translate(Temporal::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
+				$rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . L10n::t('[today]') : '');
 				$rr['startime'] = $strt;
 				$rr['today'] = $today;
 
@@ -731,8 +731,8 @@ class Profile
 
 				$val = day_translate(
 					intval($a->profile['dob']) ?
-						Temporal::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
-						: Temporal::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
+						DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
+						: DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
 				);
 
 				$profile['birthday'] = [L10n::t('Birthday:'), $val];
diff --git a/src/Model/Queue.php b/src/Model/Queue.php
index 6c49ff4d1..da7a8b3e5 100644
--- a/src/Model/Queue.php
+++ b/src/Model/Queue.php
@@ -6,7 +6,7 @@ namespace Friendica\Model;
 
 use Friendica\Core\Config;
 use Friendica\Database\DBM;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -20,7 +20,7 @@ class Queue
 	public static function updateTime($id)
 	{
 		logger('queue: requeue item ' . $id);
-		dba::update('queue', ['last' => Temporal::utcNow()], ['id' => $id]);
+		dba::update('queue', ['last' => DateTimeFormat::utcNow()], ['id' => $id]);
 	}
 
 	/**
@@ -95,6 +95,13 @@ class Queue
 			}
 		}
 
-		dba::insert('queue', ['cid' => $cid, 'network' => $network, 'created' => Temporal::utcNow(), 'last' => Temporal::utcNow(), 'content' => $msg, 'batch' =>($batch) ? 1 : 0]);
+		dba::insert('queue', [
+			'cid'     => $cid,
+			'network' => $network,
+			'created' => DateTimeFormat::utcNow(),
+			'last'    => DateTimeFormat::utcNow(),
+			'content' => $msg,
+			'batch'   =>($batch) ? 1 : 0
+		]);
 	}
 }
diff --git a/src/Model/User.php b/src/Model/User.php
index 3ef2a4595..7cf7fea2e 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -17,8 +17,8 @@ use Friendica\Model\Group;
 use Friendica\Model\Photo;
 use Friendica\Object\Image;
 use Friendica\Util\Crypto;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 use Exception;
 use LightOpenID;
@@ -396,7 +396,7 @@ class User
 			'verified' => $verified,
 			'blocked'  => $blocked,
 			'timezone' => 'UTC',
-			'register_date' => Temporal::utcNow(),
+			'register_date' => DateTimeFormat::utcNow(),
 			'default-location' => ''
 		]);
 
@@ -613,7 +613,7 @@ class User
 		dba::insert('userd', ['username' => $user['nickname']]);
 
 		// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
-		dba::update('user', ['account_removed' => true, 'account_expires_on' => Temporal::utcNow()], ['uid' => $uid]);
+		dba::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
 		Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
 
 		// Send an update to the directory
diff --git a/src/Module/Login.php b/src/Module/Login.php
index 0a48392f8..53ab57585 100644
--- a/src/Module/Login.php
+++ b/src/Module/Login.php
@@ -10,8 +10,8 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Database\DBM;
 use Friendica\Model\User;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 use Exception;
 use LightOpenID;
@@ -121,7 +121,7 @@ class Login extends BaseModule
 
 			// if we haven't failed up this point, log them in.
 			$_SESSION['remember'] = $_POST['remember'];
-			$_SESSION['last_login_date'] = Temporal::utcNow();
+			$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
 			authenticate_success($record, true, true);
 
 			if (x($_SESSION, 'return_url')) {
@@ -220,10 +220,10 @@ class Login extends BaseModule
 				// stays logged in for a long time, e.g. with "Remember Me"
 				$login_refresh = false;
 				if (!x($_SESSION['last_login_date'])) {
-					$_SESSION['last_login_date'] = Temporal::utcNow();
+					$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
 				}
-				if (strcmp(Temporal::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
-					$_SESSION['last_login_date'] = Temporal::utcNow();
+				if (strcmp(DateTimeFormat::utc('now - 12 hours'), $_SESSION['last_login_date']) > 0) {
+					$_SESSION['last_login_date'] = DateTimeFormat::utcNow();
 					$login_refresh = true;
 				}
 				authenticate_success($user, false, false, $login_refresh);
diff --git a/src/Network/FKOAuth1.php b/src/Network/FKOAuth1.php
index f7f8f1641..8af267be3 100644
--- a/src/Network/FKOAuth1.php
+++ b/src/Network/FKOAuth1.php
@@ -9,7 +9,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Network\FKOAuthDataStore;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 use OAuthServer;
 use OAuthSignatureMethod_HMAC_SHA1;
@@ -68,7 +68,7 @@ class FKOAuth1 extends OAuthServer
 			$_SESSION['cid'] = $a->cid;
 		}
 
-		dba::update('user', ['login_date' => Temporal::utcNow()], ['uid' => $_SESSION['uid']]);
+		dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
 
 		Addon::callHooks('logged_in', $a->user);
 	}
diff --git a/src/Object/Post.php b/src/Object/Post.php
index 4e83d2ff9..198ca6580 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -13,7 +13,7 @@ use Friendica\Core\PConfig;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -124,7 +124,7 @@ class Post extends BaseObject
 		if (strtotime($item['edited']) - strtotime($item['created']) > 1) {
 			$edited = [
 				'label'    => L10n::t('This entry was edited'),
-				'date'     => Temporal::local($item['edited'], 'r'),
+				'date'     => DateTimeFormat::local($item['edited'], 'r'),
 				'relative' => relative_date($item['edited'])
 			];
 		}
@@ -301,7 +301,7 @@ class Post extends BaseObject
 
 		$comment = $this->getCommentBox($indent);
 
-		if (strcmp(Temporal::utc($item['created']), Temporal::utc('now - 12 hours')) > 0) {
+		if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
 			$shiny = 'shiny';
 		}
 
@@ -364,7 +364,7 @@ class Post extends BaseObject
 			'osparkle'        => $osparkle,
 			'sparkle'         => $sparkle,
 			'title'           => $title_e,
-			'localtime'       => Temporal::local($item['created'], 'r'),
+			'localtime'       => DateTimeFormat::local($item['created'], 'r'),
 			'ago'             => $item['app'] ? L10n::t('%s from %s', relative_date($item['created']), $item['app']) : relative_date($item['created']),
 			'app'             => $item['app'],
 			'created'         => relative_date($item['created']),
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 9eb226689..2269bffcf 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -26,8 +26,8 @@ use Friendica\Model\User;
 use Friendica\Object\Image;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\Crypto;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use Friendica\Content\Text\BBCode;
 
@@ -229,7 +229,7 @@ class DFRN
 			}
 		}
 
-		$check_date = Temporal::utc($last_update);
+		$check_date = DateTimeFormat::utc($last_update);
 
 		$r = q(
 			"SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -421,7 +421,7 @@ class DFRN
 
 		XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
 		XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
-		XML::addElement($doc, $mail, "dfrn:sentdate", Temporal::utc($item['created'] . '+00:00', Temporal::ATOM));
+		XML::addElement($doc, $mail, "dfrn:sentdate", DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
 		XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
 		XML::addElement($doc, $mail, "dfrn:content", $item['body']);
 
@@ -587,7 +587,7 @@ class DFRN
 
 		/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
 
-		XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
+		XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
 
 		$author = self::addAuthor($doc, $owner, $authorelement, $public);
 		$root->appendChild($author);
@@ -622,9 +622,9 @@ class DFRN
 
 		$author = $doc->createElement($authorelement);
 
-		$namdate = Temporal::utc($owner['name-date'].'+00:00', Temporal::ATOM);
-		$uridate = Temporal::utc($owner['uri-date'].'+00:00', Temporal::ATOM);
-		$picdate = Temporal::utc($owner['avatar-date'].'+00:00', Temporal::ATOM);
+		$namdate = DateTimeFormat::utc($owner['name-date'].'+00:00', DateTimeFormat::ATOM);
+		$uridate = DateTimeFormat::utc($owner['uri-date'].'+00:00', DateTimeFormat::ATOM);
+		$picdate = DateTimeFormat::utc($owner['avatar-date'].'+00:00', DateTimeFormat::ATOM);
 
 		$attributes = [];
 
@@ -903,7 +903,7 @@ class DFRN
 		}
 
 		if ($item['deleted']) {
-			$attributes = ["ref" => $item['uri'], "when" => Temporal::utc($item['edited'] . '+00:00', Temporal::ATOM)];
+			$attributes = ["ref" => $item['uri'], "when" => DateTimeFormat::utc($item['edited'] . '+00:00', DateTimeFormat::ATOM)];
 			return XML::createElement($doc, "at:deleted-entry", "", $attributes);
 		}
 
@@ -983,8 +983,8 @@ class DFRN
 		XML::addElement($doc, $entry, "id", $item["uri"]);
 		XML::addElement($doc, $entry, "title", $item["title"]);
 
-		XML::addElement($doc, $entry, "published", Temporal::utc($item["created"] . "+00:00", Temporal::ATOM));
-		XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"] . "+00:00", Temporal::ATOM));
+		XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"] . "+00:00", DateTimeFormat::ATOM));
+		XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"] . "+00:00", DateTimeFormat::ATOM));
 
 		// "dfrn:env" is used to read the content
 		XML::addElement($doc, $entry, "dfrn:env", base64url_encode($body, true));
@@ -1388,7 +1388,7 @@ class DFRN
 			"SELECT `id` FROM `event` WHERE `uid` = %d AND `cid` = %d AND `start` = '%s' AND `type` = '%s' LIMIT 1",
 			intval($contact["uid"]),
 			intval($contact["id"]),
-			dbesc(Temporal::utc($birthday)),
+			dbesc(DateTimeFormat::utc($birthday)),
 			dbesc("birthday")
 		);
 
@@ -1406,10 +1406,10 @@ class DFRN
 			VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
 			intval($contact["uid"]),
 			intval($contact["id"]),
-			dbesc(Temporal::utcNow()),
-			dbesc(Temporal::utcNow()),
-			dbesc(Temporal::utc($birthday)),
-			dbesc(Temporal::utc($birthday . " + 1 day ")),
+			dbesc(DateTimeFormat::utcNow()),
+			dbesc(DateTimeFormat::utcNow()),
+			dbesc(DateTimeFormat::utc($birthday)),
+			dbesc(DateTimeFormat::utc($birthday . " + 1 day ")),
 			dbesc($bdtext),
 			dbesc($bdtext2),
 			dbesc("birthday")
@@ -1889,7 +1889,7 @@ class DFRN
 			intval($suggest["cid"]),
 			dbesc($suggest["body"]),
 			dbesc($hash),
-			dbesc(Temporal::utcNow()),
+			dbesc(DateTimeFormat::utcNow()),
 			intval(0)
 		);
 
@@ -2081,13 +2081,13 @@ class DFRN
 
 		if (self::isEditedTimestampNewer($current, $item)) {
 			// do not accept (ignore) an earlier edit than one we currently have.
-			if (Temporal::utc($item["edited"]) < $current["edited"]) {
+			if (DateTimeFormat::utc($item["edited"]) < $current["edited"]) {
 				return false;
 			}
 
 			$fields = ['title' => $item["title"], 'body' => $item["body"],
-					'tag' => $item["tag"], 'changed' => Temporal::utcNow(),
-					'edited' => Temporal::utc($item["edited"])];
+					'tag' => $item["tag"], 'changed' => DateTimeFormat::utcNow(),
+					'edited' => DateTimeFormat::utc($item["edited"])];
 
 			$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
 			dba::update('item', $fields, $condition);
@@ -2422,7 +2422,7 @@ class DFRN
 
 		// Is there an existing item?
 		if (DBM::is_result($current) && self::isEditedTimestampNewer($current[0], $item)
-			&& (Temporal::utc($item["edited"]) < $current[0]["edited"])
+			&& (DateTimeFormat::utc($item["edited"]) < $current[0]["edited"])
 		) {
 			logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
 			return;
@@ -2753,9 +2753,9 @@ class DFRN
 			}
 		}
 		if ($when) {
-			$when = Temporal::utc($when);
+			$when = DateTimeFormat::utc($when);
 		} else {
-			$when = Temporal::utcNow();
+			$when = DateTimeFormat::utcNow();
 		}
 
 		if (!$uri || !$importer["id"]) {
@@ -2836,7 +2836,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `parent-uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(Temporal::utcNow()),
+					dbesc(DateTimeFormat::utcNow()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
@@ -2849,7 +2849,7 @@ class DFRN
 						`body` = '', `title` = ''
 					WHERE `uri` = '%s' AND `uid` IN (0, %d)",
 					dbesc($when),
-					dbesc(Temporal::utcNow()),
+					dbesc(DateTimeFormat::utcNow()),
 					dbesc($uri),
 					intval($importer["uid"])
 				);
@@ -3157,8 +3157,8 @@ class DFRN
 			return false;
 		}
 
-		$existing_edited = Temporal::utc($existing['edited']);
-		$update_edited = Temporal::utc($update['edited']);
+		$existing_edited = DateTimeFormat::utc($existing['edited']);
+		$update_edited = DateTimeFormat::utc($update['edited']);
 
 		return (strcmp($existing_edited, $update_edited) < 0);
 	}
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index 077c93c29..1e5c5345f 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -9,12 +9,11 @@
  */
 namespace Friendica\Protocol;
 
-use Friendica\App;
-use Friendica\Core\System;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
@@ -26,8 +25,8 @@ use Friendica\Model\Queue;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use dba;
 use SimpleXMLElement;
@@ -77,7 +76,7 @@ class Diaspora
 				$r = q(
 					"INSERT INTO `contact` (`uid`, `created`, `name`, `nick`, `addr`, `url`, `nurl`, `batch`, `network`, `rel`, `blocked`, `pending`, `writable`, `name-date`, `uri-date`, `avatar-date`)
 					VALUES (0, '%s', '%s', 'relay', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, '%s', '%s', '%s')",
-					Temporal::utcNow(),
+					DateTimeFormat::utcNow(),
 					dbesc($addr),
 					dbesc($addr),
 					dbesc($server),
@@ -85,9 +84,9 @@ class Diaspora
 					dbesc($batch),
 					dbesc(NETWORK_DIASPORA),
 					intval(CONTACT_IS_FOLLOWER),
-					dbesc(Temporal::utcNow()),
-					dbesc(Temporal::utcNow()),
-					dbesc(Temporal::utcNow())
+					dbesc(DateTimeFormat::utcNow()),
+					dbesc(DateTimeFormat::utcNow()),
+					dbesc(DateTimeFormat::utcNow())
 				);
 
 				$relais = q("SELECT `batch`, `id`, `name`,`network` FROM `contact` WHERE `uid` = 0 AND `batch` = '%s' LIMIT 1", dbesc($batch));
@@ -871,7 +870,7 @@ class Diaspora
 				dbesc($arr["confirm"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(Temporal::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
 				dbesc($arr["url"]),
 				dbesc($arr["network"])
 			);
@@ -894,7 +893,7 @@ class Diaspora
 				dbesc($arr["network"]),
 				dbesc($arr["alias"]),
 				dbesc($arr["pubkey"]),
-				dbesc(Temporal::utcNow())
+				dbesc(DateTimeFormat::utcNow())
 			);
 		}
 
@@ -1654,9 +1653,9 @@ class Diaspora
 		$text = unxmlify($data->text);
 
 		if (isset($data->created_at)) {
-			$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
+			$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
 		} else {
-			$created_at = Temporal::utcNow();
+			$created_at = DateTimeFormat::utcNow();
 		}
 
 		if (isset($data->thread_parent_guid)) {
@@ -1786,7 +1785,7 @@ class Diaspora
 		$msg_guid = notags(unxmlify($mesg->guid));
 		$msg_conversation_guid = notags(unxmlify($mesg->conversation_guid));
 		$msg_text = unxmlify($mesg->text);
-		$msg_created_at = Temporal::utc(notags(unxmlify($mesg->created_at)));
+		$msg_created_at = DateTimeFormat::utc(notags(unxmlify($mesg->created_at)));
 
 		if ($msg_conversation_guid != $guid) {
 			logger("message conversation guid does not belong to the current conversation.");
@@ -1831,7 +1830,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
 
 		notification(
 			[
@@ -1865,7 +1864,7 @@ class Diaspora
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
 		$subject = notags(unxmlify($data->subject));
-		$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
+		$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
 		$participants = notags(unxmlify($data->participants));
 
 		$messages = $data->message;
@@ -1897,7 +1896,7 @@ class Diaspora
 				dbesc($guid),
 				dbesc($author),
 				dbesc($created_at),
-				dbesc(Temporal::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
 				dbesc($subject),
 				dbesc($participants)
 			);
@@ -2098,7 +2097,7 @@ class Diaspora
 		$guid = notags(unxmlify($data->guid));
 		$conversation_guid = notags(unxmlify($data->conversation_guid));
 		$text = unxmlify($data->text);
-		$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
+		$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
 
 		$contact = self::allowedContactByHandle($importer, $author, true);
 		if (!$contact) {
@@ -2164,7 +2163,7 @@ class Diaspora
 
 		dba::unlock();
 
-		dba::update('conv', ['updated' => Temporal::utcNow()], ['id' => $conversation["id"]]);
+		dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
 		return true;
 	}
 
@@ -2315,7 +2314,7 @@ class Diaspora
 		$birthday = str_replace("1000", "1901", $birthday);
 
 		if ($birthday != "") {
-			$birthday = Temporal::utc($birthday, "Y-m-d");
+			$birthday = DateTimeFormat::utc($birthday, "Y-m-d");
 		}
 
 		// this is to prevent multiple birthday notifications in a single year
@@ -2331,7 +2330,7 @@ class Diaspora
 			dbesc($name),
 			dbesc($nick),
 			dbesc($author),
-			dbesc(Temporal::utcNow()),
+			dbesc(DateTimeFormat::utcNow()),
 			dbesc($birthday),
 			dbesc($location),
 			dbesc($about),
@@ -2537,7 +2536,7 @@ class Diaspora
 			intval($importer["uid"]),
 			dbesc($ret["network"]),
 			dbesc($ret["addr"]),
-			Temporal::utcNow(),
+			DateTimeFormat::utcNow(),
 			dbesc($ret["url"]),
 			dbesc(normalise_link($ret["url"])),
 			dbesc($batch),
@@ -2580,7 +2579,7 @@ class Diaspora
 				0,
 				dbesc(L10n::t("Sharing notification from Diaspora network")),
 				dbesc($hash),
-				dbesc(Temporal::utcNow())
+				dbesc(DateTimeFormat::utcNow())
 			);
 		} else {
 			// automatic friend approval
@@ -2611,8 +2610,8 @@ class Diaspora
 				WHERE `id` = %d
 				",
 				intval($new_relation),
-				dbesc(Temporal::utcNow()),
-				dbesc(Temporal::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
+				dbesc(DateTimeFormat::utcNow()),
 				intval($contact_record["id"])
 			);
 
@@ -2716,7 +2715,7 @@ class Diaspora
 	{
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
-		$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
+		$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
 		$root_author = notags(unxmlify($data->root_author));
 		$root_guid = notags(unxmlify($data->root_guid));
 		/// @todo handle unprocessed property "provider_display_name"
@@ -2852,8 +2851,8 @@ class Diaspora
 					'deleted' => true,
 					'title' => '',
 					'body' => '',
-					'edited' => Temporal::utcNow(),
-					'changed' => Temporal::utcNow()],
+					'edited' => DateTimeFormat::utcNow(),
+					'changed' => DateTimeFormat::utcNow()],
 				['id' => $item["id"]]
 			);
 
@@ -2930,7 +2929,7 @@ class Diaspora
 	{
 		$author = notags(unxmlify($data->author));
 		$guid = notags(unxmlify($data->guid));
-		$created_at = Temporal::utc(notags(unxmlify($data->created_at)));
+		$created_at = DateTimeFormat::utc(notags(unxmlify($data->created_at)));
 		$public = notags(unxmlify($data->public));
 		$text = unxmlify($data->text);
 		$provider_display_name = notags(unxmlify($data->provider_display_name));
@@ -3593,7 +3592,7 @@ class Diaspora
 			$eventdata['guid'] = $event['guid'];
 		}
 
-		$mask = Temporal::ATOM;
+		$mask = DateTimeFormat::ATOM;
 
 		/// @todo - establish "all day" events in Friendica
 		$eventdata["all_day"] = "false";
@@ -3607,10 +3606,10 @@ class Diaspora
 		}
 
 		if ($event['start']) {
-			$eventdata['start'] = Temporal::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
+			$eventdata['start'] = DateTimeFormat::convert($event['start'], "UTC", $eventdata['timezone'], $mask);
 		}
 		if ($event['finish'] && !$event['nofinish']) {
-			$eventdata['end'] = Temporal::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
+			$eventdata['end'] = DateTimeFormat::convert($event['finish'], "UTC", $eventdata['timezone'], $mask);
 		}
 		if ($event['summary']) {
 			$eventdata['summary'] = html_entity_decode(bb2diaspora($event['summary']));
@@ -3652,7 +3651,7 @@ class Diaspora
 
 		$public = (($item["private"]) ? "false" : "true");
 
-		$created = Temporal::utc($item["created"], Temporal::ATOM);
+		$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
 
 		// Detect a share element and do a reshare
 		if (!$item['private'] && ($ret = self::isReshare($item["body"]))) {
@@ -3855,7 +3854,7 @@ class Diaspora
 		$parent = $p[0];
 
 		$text = html_entity_decode(bb2diaspora($item["body"]));
-		$created = Temporal::utc($item["created"], Temporal::ATOM);
+		$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
 
 		$comment = ["author" => self::myHandle($owner),
 				"guid" => $item["guid"],
@@ -4086,12 +4085,12 @@ class Diaspora
 			"author" => $cnv["creator"],
 			"guid" => $cnv["guid"],
 			"subject" => $cnv["subject"],
-			"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
+			"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
 			"participants" => $cnv["recips"]
 		];
 
 		$body = bb2diaspora($item["body"]);
-		$created = Temporal::utc($item["created"], Temporal::ATOM);
+		$created = DateTimeFormat::utc($item["created"], DateTimeFormat::ATOM);
 
 		$msg = [
 			"author" => $myaddr,
@@ -4109,7 +4108,7 @@ class Diaspora
 					"author" => $cnv["creator"],
 					"guid" => $cnv["guid"],
 					"subject" => $cnv["subject"],
-					"created_at" => Temporal::utc($cnv['created'], Temporal::ATOM),
+					"created_at" => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
 					"participants" => $cnv["recips"],
 					"message" => $msg];
 
@@ -4217,7 +4216,7 @@ class Diaspora
 				if ($year < 1004) {
 					$year = 1004;
 				}
-				$dob = Temporal::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
+				$dob = DateTimeFormat::utc($year . '-' . $month . '-'. $day, 'Y-m-d');
 			}
 
 			$about = $profile['about'];
diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php
index 0583e0cee..e4894cf54 100644
--- a/src/Protocol/OStatus.php
+++ b/src/Protocol/OStatus.php
@@ -16,9 +16,9 @@ use Friendica\Model\GContact;
 use Friendica\Model\Item;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Lock;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use Friendica\Util\XML;
 use dba;
 use DOMDocument;
@@ -199,7 +199,7 @@ class OStatus
 				$contact["location"] = $value;
 			}
 
-			$contact['name-date'] = Temporal::utcNow();
+			$contact['name-date'] = DateTimeFormat::utcNow();
 
 			dba::update('contact', $contact, ['id' => $contact["id"]], $current);
 
@@ -220,7 +220,7 @@ class OStatus
 						'nurl' => normalise_link($author["author-link"]),
 						'nick' => $contact["nick"], 'alias' => $contact["alias"],
 						'about' => $contact["about"], 'location' => $contact["location"],
-						'success_update' => Temporal::utcNow(), 'last-update' => Temporal::utcNow()];
+						'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
 
 				dba::update('contact', $fields, ['id' => $cid], $old_contact);
 
@@ -558,7 +558,7 @@ class OStatus
 		dba::update(
 			'item',
 			['deleted' => true, 'title' => '', 'body' => '',
-					'edited' => Temporal::utcNow(), 'changed' => Temporal::utcNow()],
+					'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()],
 			['id' => $deleted["id"]]
 		);
 
@@ -1273,7 +1273,7 @@ class OStatus
 		XML::addElement($doc, $root, "title", $title);
 		XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
 		XML::addElement($doc, $root, "logo", $owner["photo"]);
-		XML::addElement($doc, $root, "updated", Temporal::utcNow(Temporal::ATOM));
+		XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
 
 		$author = self::addAuthor($doc, $owner);
 		$root->appendChild($author);
@@ -1539,7 +1539,7 @@ class OStatus
 		XML::addElement($doc, $source, "link", "", ["rel" => "alternate", "type" => "text/html", "href" => $contact["alias"]]);
 		XML::addElement($doc, $source, "link", "", ["rel" => "self", "type" => "application/atom+xml", "href" => $contact["poll"]]);
 		XML::addElement($doc, $source, "icon", $contact["photo"]);
-		XML::addElement($doc, $source, "updated", Temporal::utc($contact["success_update"]."+00:00", Temporal::ATOM));
+		XML::addElement($doc, $source, "updated", DateTimeFormat::utc($contact["success_update"]."+00:00", DateTimeFormat::ATOM));
 
 		return $source;
 	}
@@ -1923,8 +1923,8 @@ class OStatus
 
 		XML::addElement($doc, $entry, "activity:verb", $verb);
 
-		XML::addElement($doc, $entry, "published", Temporal::utc($item["created"]."+00:00", Temporal::ATOM));
-		XML::addElement($doc, $entry, "updated", Temporal::utc($item["edited"]."+00:00", Temporal::ATOM));
+		XML::addElement($doc, $entry, "published", DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM));
+		XML::addElement($doc, $entry, "updated", DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM));
 	}
 
 	/**
@@ -2127,7 +2127,7 @@ class OStatus
 			$last_update = 'now -30 days';
 		}
 
-		$check_date = Temporal::utc($last_update);
+		$check_date = DateTimeFormat::utc($last_update);
 		$authorid = Contact::getIdForURL($owner["url"], 0);
 
 		$sql_extra = '';
diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php
index aea68eb99..7f351ed05 100644
--- a/src/Protocol/PortableContact.php
+++ b/src/Protocol/PortableContact.php
@@ -15,8 +15,8 @@ use Friendica\Database\DBM;
 use Friendica\Model\GContact;
 use Friendica\Model\Profile;
 use Friendica\Network\Probe;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 use dba;
 use DOMDocument;
 use DOMXPath;
@@ -144,7 +144,7 @@ class PortableContact
 			}
 
 			if (isset($entry->updated)) {
-				$updated = date(Temporal::MYSQL, strtotime($entry->updated));
+				$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
 			}
 
 			if (isset($entry->network)) {
@@ -315,7 +315,7 @@ class PortableContact
 		$contact = ["url" => $profile];
 
 		if ($gcontacts[0]["created"] <= NULL_DATE) {
-			$contact['created'] = Temporal::utcNow();
+			$contact['created'] = DateTimeFormat::utcNow();
 		}
 
 		if ($force) {
@@ -338,7 +338,7 @@ class PortableContact
 		if ($server_url != "") {
 			if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
 				if ($force) {
-					$fields = ['last_failure' => Temporal::utcNow()];
+					$fields = ['last_failure' => DateTimeFormat::utcNow()];
 					dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 				}
 
@@ -412,14 +412,14 @@ class PortableContact
 
 						// Set the date of the last contact
 						/// @todo By now the function "update_gcontact" doesn't work with this field
-						//$contact["last_contact"] = Temporal::utcNow();
+						//$contact["last_contact"] = DateTimeFormat::utcNow();
 
 						$contact = array_merge($contact, $noscrape);
 
 						GContact::update($contact);
 
 						if (trim($noscrape["updated"]) != "") {
-							$fields = ['last_contact' => Temporal::utcNow()];
+							$fields = ['last_contact' => DateTimeFormat::utcNow()];
 							dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 							logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
@@ -468,7 +468,7 @@ class PortableContact
 		}
 
 		if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
-			$fields = ['last_failure' => Temporal::utcNow()];
+			$fields = ['last_failure' => DateTimeFormat::utcNow()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
@@ -484,7 +484,7 @@ class PortableContact
 		$feedret = Network::curl($data["poll"]);
 
 		if (!$feedret["success"]) {
-			$fields = ['last_failure' => Temporal::utcNow()];
+			$fields = ['last_failure' => DateTimeFormat::utcNow()];
 			dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
 			logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
@@ -533,7 +533,7 @@ class PortableContact
 
 	public static function updateNeeded($created, $updated, $last_failure, $last_contact)
 	{
-		$now = strtotime(Temporal::utcNow());
+		$now = strtotime(DateTimeFormat::utcNow());
 
 		if ($updated > $last_contact) {
 			$contact_time = strtotime($updated);
@@ -922,7 +922,7 @@ class PortableContact
 		$gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
 		if (DBM::is_result($gserver)) {
 			if ($gserver["created"] <= NULL_DATE) {
-				$fields = ['created' => Temporal::utcNow()];
+				$fields = ['created' => DateTimeFormat::utcNow()];
 				$condition = ['nurl' => normalise_link($server_url)];
 				dba::update('gserver', $fields, $condition);
 			}
@@ -969,7 +969,7 @@ class PortableContact
 		// Mastodon uses the "@" for user profiles.
 		// But this can be misunderstood.
 		if (parse_url($server_url, PHP_URL_USER) != '') {
-			dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -985,7 +985,7 @@ class PortableContact
 		if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
 			($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
 			logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-			dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
+			dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
 			return false;
 		}
 
@@ -1000,7 +1000,7 @@ class PortableContact
 			// Quit if there is a timeout
 			if ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
-				dba::update('gserver', ['last_failure' => Temporal::utcNow()], ['nurl' => normalise_link($server_url)]);
+				dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
 				return false;
 			}
 
@@ -1332,9 +1332,9 @@ class PortableContact
 
 		if ($failure) {
 			$last_contact = $orig_last_contact;
-			$last_failure = Temporal::utcNow();
+			$last_failure = DateTimeFormat::utcNow();
 		} else {
-			$last_contact = Temporal::utcNow();
+			$last_contact = DateTimeFormat::utcNow();
 			$last_failure = $orig_last_failure;
 		}
 
@@ -1362,7 +1362,7 @@ class PortableContact
 			dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
 		} elseif (!$failure) {
 			$fields['nurl'] = normalise_link($server_url);
-			$fields['created'] = Temporal::utcNow();
+			$fields['created'] = DateTimeFormat::utcNow();
 			dba::insert('gserver', $fields);
 		}
 		logger("End discovery for server " . $server_url, LOGGER_DEBUG);
@@ -1507,7 +1507,7 @@ class PortableContact
 					$timeframe = 30;
 				}
 
-				$updatedSince = date(Temporal::MYSQL, time() - $timeframe * 86400);
+				$updatedSince = date(DateTimeFormat::MYSQL, time() - $timeframe * 86400);
 
 				// Fetch all global contacts from the other server (Not working with Redmatrix and Friendica versions before 3.3)
 				$url = $server["poco"]."/@global?updatedSince=".$updatedSince."&fields=displayName,urls,photos,updated,network,aboutMe,currentLocation,tags,gender,contactType,generation";
@@ -1526,7 +1526,7 @@ class PortableContact
 				}
 			}
 
-			$fields = ['last_poco_query' => Temporal::utcNow()];
+			$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return true;
@@ -1535,7 +1535,7 @@ class PortableContact
 			self::checkServer($server["url"], $server["network"], true);
 
 			// If we couldn't reach the server, we will try it some time later
-			$fields = ['last_poco_query' => Temporal::utcNow()];
+			$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
 			dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 
 			return false;
@@ -1561,7 +1561,7 @@ class PortableContact
 			foreach ($r as $server) {
 				if (!self::checkServer($server["url"], $server["network"])) {
 					// The server is not reachable? Okay, then we will try it later
-					$fields = ['last_poco_query' => Temporal::utcNow()];
+					$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
 					dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
 					continue;
 				}
@@ -1654,7 +1654,7 @@ class PortableContact
 			}
 
 			if (isset($entry->updated)) {
-				$updated = date(Temporal::MYSQL, strtotime($entry->updated));
+				$updated = date(DateTimeFormat::MYSQL, strtotime($entry->updated));
 			}
 
 			if (isset($entry->network)) {
diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php
new file mode 100644
index 000000000..10810da03
--- /dev/null
+++ b/src/Util/DateTimeFormat.php
@@ -0,0 +1,139 @@
+format($format));
+		}
+
+		try {
+			$from_obj = new DateTimeZone($tz_from);
+		} catch (Exception $e) {
+			$from_obj = new DateTimeZone('UTC');
+		}
+
+		try {
+			$d = new DateTime($s, $from_obj);
+		} catch (Exception $e) {
+			logger('datetime_convert: exception: ' . $e->getMessage());
+			$d = new DateTime('now', $from_obj);
+		}
+
+		try {
+			$to_obj = new DateTimeZone($tz_to);
+		} catch (Exception $e) {
+			$to_obj = new DateTimeZone('UTC');
+		}
+
+		$d->setTimeZone($to_obj);
+
+		return $d->format($format);
+	}
+}
diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php
index 3074e74dd..e8094959d 100644
--- a/src/Util/ParseUrl.php
+++ b/src/Util/ParseUrl.php
@@ -73,7 +73,7 @@ class ParseUrl
 			[
 				'url' => normalise_link($url), 'guessing' => !$no_guessing,
 				'oembed' => $do_oembed, 'content' => serialize($data),
-				'created' => Temporal::utcNow()
+				'created' => DateTimeFormat::utcNow()
 			],
 			true
 		);
diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php
index 0e8c8f18c..e04165069 100644
--- a/src/Util/Temporal.php
+++ b/src/Util/Temporal.php
@@ -8,7 +8,6 @@ namespace Friendica\Util;
 
 use DateTime;
 use DateTimeZone;
-use Exception;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
@@ -21,9 +20,6 @@ require_once 'include/text.php';
  */
 class Temporal
 {
-	const ATOM = 'Y-m-d\TH:i:s\Z';
-	const MYSQL = 'Y-m-d H:i:s';
-
 	/**
 	 * @brief Two-level sort for timezones.
 	 *
@@ -123,125 +119,6 @@ class Temporal
 		]);
 	}
 
-	/**
-	 * convert() shorthand for UTC.
-	 *
-	 * @param string $time   A date/time string
-	 * @param string $format DateTime format string or Temporal constant
-	 * @return string
-	 */
-	public static function utc($time, $format = self::MYSQL)
-	{
-		return self::convert($time, 'UTC', 'UTC', $format);
-	}
-
-	/**
-	 * convert() shorthand for local.
-	 *
-	 * @param string $time   A date/time string
-	 * @param string $format DateTime format string or Temporal constant
-	 * @return string
-	 */
-	public static function local($time, $format = self::MYSQL)
-	{
-		return self::convert($time, date_default_timezone_get(), 'UTC', $format);
-	}
-
-	/**
-	 * convert() shorthand for timezoned now.
-	 *
-	 * @param string $format DateTime format string or Temporal constant
-	 * @return string
-	 */
-	public static function timezoneNow($timezone, $format = self::MYSQL)
-	{
-		return self::convert('now', $timezone, 'UTC', $format);
-	}
-
-	/**
-	 * convert() shorthand for local now.
-	 *
-	 * @param string $format DateTime format string or Temporal constant
-	 * @return string
-	 */
-	public static function localNow($format = self::MYSQL)
-	{
-		return self::local('now', $format);
-	}
-
-	/**
-	 * convert() shorthand for UTC now.
-	 *
-	 * @param string $format DateTime format string or Temporal constant
-	 * @return string
-	 */
-	public static function utcNow($format = self::MYSQL)
-	{
-		return self::utc('now', $format);
-	}
-
-	/**
-	 * @brief General purpose date parse/convert/format function.
-	 *
-	 * @param string $s       Some parseable date/time string
-	 * @param string $tz_to   Destination timezone
-	 * @param string $tz_from Source timezone
-	 * @param string $format  Output format recognised from php's DateTime class
-	 *   http://www.php.net/manual/en/datetime.format.php
-	 *
-	 * @return string Formatted date according to given format
-	 */
-	public static function convert($s = 'now', $tz_to = 'UTC', $tz_from = 'UTC', $format = self::MYSQL)
-	{
-		// Defaults to UTC if nothing is set, but throws an exception if set to empty string.
-		// Provide some sane defaults regardless.
-		if ($from === '') {
-			$from = 'UTC';
-		}
-
-		if ($to === '') {
-			$to = 'UTC';
-		}
-
-		if (($s === '') || (!is_string($s))) {
-			$s = 'now';
-		}
-
-		/*
-		 * Slight hackish adjustment so that 'zero' datetime actually returns what is intended
-		 * otherwise we end up with -0001-11-30 ...
-		 * add 32 days so that we at least get year 00, and then hack around the fact that
-		 * months and days always start with 1.
-		 */
-		if (substr($s, 0, 10) <= '0001-01-01') {
-			$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
-			return str_replace('1', '0', $d->format($format));
-		}
-
-		try {
-			$from_obj = new DateTimeZone($tz_from);
-		} catch (Exception $e) {
-			$from_obj = new DateTimeZone('UTC');
-		}
-
-		try {
-			$d = new DateTime($s, $from_obj);
-		} catch (Exception $e) {
-			logger('datetime_convert: exception: ' . $e->getMessage());
-			$d = new DateTime('now', $from_obj);
-		}
-
-		try {
-			$to_obj = new DateTimeZone($tz_to);
-		} catch (Exception $e) {
-			$to_obj = new DateTimeZone('UTC');
-		}
-
-		$d->setTimeZone($to_obj);
-
-		return $d->format($format);
-	}
-
 	/**
 	 * @brief Wrapper for date selector, tailored for use in birthday fields.
 	 *
diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php
index 9c68a7fea..7c8e5bc0f 100644
--- a/src/Worker/Cron.php
+++ b/src/Worker/Cron.php
@@ -8,7 +8,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -71,7 +71,7 @@ Class Cron {
 
 		// once daily run birthday_updates and then expire in background
 		$d1 = Config::get('system', 'last_expire_day');
-		$d2 = intval(Temporal::utcNow('d'));
+		$d2 = intval(DateTimeFormat::utcNow('d'));
 
 		if ($d2 != intval($d1)) {
 
@@ -142,7 +142,7 @@ Class Cron {
 
 		Addon::reload();
 
-		$d = Temporal::utcNow();
+		$d = DateTimeFormat::utcNow();
 
 		// Only poll from those with suitable relationships,
 		// and which have a polling address and ignore Diaspora since
@@ -218,33 +218,33 @@ Class Cron {
 				 */
 				switch ($contact['priority']) {
 					case 5:
-						if (Temporal::utcNow() > Temporal::utc($t . " + 1 month")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 month")) {
 							$update = true;
 						}
 						break;
 					case 4:
-						if (Temporal::utcNow() > Temporal::utc($t . " + 1 week")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 week")) {
 							$update = true;
 						}
 						break;
 					case 3:
-						if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 day")) {
 							$update = true;
 						}
 						break;
 					case 2:
-						if (Temporal::utcNow() > Temporal::utc($t . " + 12 hour")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 12 hour")) {
 							$update = true;
 						}
 						break;
 					case 1:
-						if (Temporal::utcNow() > Temporal::utc($t . " + 1 hour")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 hour")) {
 							$update = true;
 						}
 						break;
 					case 0:
 					default:
-						if (Temporal::utcNow() > Temporal::utc($t . " + ".$min_poll_interval." minute")) {
+						if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + ".$min_poll_interval." minute")) {
 							$update = true;
 						}
 						break;
diff --git a/src/Worker/CronHooks.php b/src/Worker/CronHooks.php
index d8b97384e..cf5759e59 100644
--- a/src/Worker/CronHooks.php
+++ b/src/Worker/CronHooks.php
@@ -8,7 +8,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Worker;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 
 Class CronHooks {
 	public static function execute($hook = '') {
@@ -45,7 +45,7 @@ Class CronHooks {
 
 		logger('cronhooks: start');
 
-		$d = Temporal::utcNow();
+		$d = DateTimeFormat::utcNow();
 
 		if (is_array($a->hooks) && array_key_exists("cron", $a->hooks)) {
 			foreach ($a->hooks["cron"] as $hook) {
diff --git a/src/Worker/DiscoverPoCo.php b/src/Worker/DiscoverPoCo.php
index 480578c8f..b3f4dab78 100644
--- a/src/Worker/DiscoverPoCo.php
+++ b/src/Worker/DiscoverPoCo.php
@@ -11,8 +11,8 @@ use Friendica\Database\DBM;
 use Friendica\Model\GContact;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
-use Friendica\Util\Temporal;
 
 require_once 'include/datetime.php';
 
@@ -198,7 +198,7 @@ class DiscoverPoCo {
 				}
 			} else {
 				q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
-					dbesc(Temporal::utcNow()), dbesc(normalise_link($user["url"])));
+					dbesc(DateTimeFormat::utcNow()), dbesc(normalise_link($user["url"])));
 			}
 
 			// Quit the loop after 3 minutes
diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php
index 0a39aafec..b95f43c38 100644
--- a/src/Worker/OnePoll.php
+++ b/src/Worker/OnePoll.php
@@ -15,6 +15,7 @@ use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
 use Friendica\Util\XML;
 use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 use dba;
 
 require_once 'include/dba.php';
@@ -44,7 +45,7 @@ class OnePoll
 			return;
 		}
 
-		$d = Temporal::utcNow();
+		$d = DateTimeFormat::utcNow();
 
 		$contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
 		if (!DBM::is_result($contact)) {
@@ -70,7 +71,7 @@ class OnePoll
 		// Diaspora users, archived users and followers are only checked if they still exist.
 		if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
 			$last_updated = PortableContact::lastUpdated($contact["url"], true);
-			$updated = Temporal::utcNow();
+			$updated = DateTimeFormat::utcNow();
 			if ($last_updated) {
 				logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
 
@@ -99,7 +100,7 @@ class OnePoll
 			$contact['priority'] = intval($poll_interval);
 			$hub_update = false;
 
-			if (Temporal::utcNow() > Temporal::utc($t . " + 1 day")) {
+			if (DateTimeFormat::utcNow() > DateTimeFormat::utc($t . " + 1 day")) {
 				$hub_update = true;
 			}
 		} else {
@@ -107,8 +108,8 @@ class OnePoll
 		}
 
 		$last_update = (($contact['last-update'] <= NULL_DATE)
-			? Temporal::utc('now - 7 days', Temporal::ATOM)
-			: Temporal::utc($contact['last-update'], Temporal::ATOM)
+			? DateTimeFormat::utc('now - 7 days', DateTimeFormat::ATOM)
+			: DateTimeFormat::utc($contact['last-update'], DateTimeFormat::ATOM)
 		);
 
 		// Update the contact entry
@@ -117,7 +118,7 @@ class OnePoll
 				logger("Skipping probably dead contact ".$contact['url']);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -126,7 +127,7 @@ class OnePoll
 				logger('Contact is marked dead');
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				return;
 			} else {
 				Contact::unmarkForArchival($contact);
@@ -137,7 +138,7 @@ class OnePoll
 			logger('Ignore public contacts');
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -149,7 +150,7 @@ class OnePoll
 			logger('No self contact for user '.$importer_uid);
 
 			// set the last-update so we don't keep polling
-			dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+			dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 			return;
 		}
 
@@ -185,7 +186,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -207,7 +208,7 @@ class OnePoll
 				Contact::markForArchival($contact);
 
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
+				$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -217,7 +218,7 @@ class OnePoll
 
 				Contact::markForArchival($contact);
 
-				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
+				$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
 				self::updateContact($contact, $fields);
 				return;
 			}
@@ -230,7 +231,7 @@ class OnePoll
 
 				// we may not be friends anymore. Will keep trying for one month.
 				// set the last-update so we don't keep polling
-				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
+				$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
 				self::updateContact($contact, $fields);
 
 				Contact::markForArchival($contact);
@@ -241,7 +242,7 @@ class OnePoll
 
 			if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -276,7 +277,7 @@ class OnePoll
 				logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
 
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -311,7 +312,7 @@ class OnePoll
 
 			if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				return;
 			}
 
@@ -321,7 +322,7 @@ class OnePoll
 
 			if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -335,7 +336,7 @@ class OnePoll
 			$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
 			if ($mail_disabled) {
 				// set the last-update so we don't keep polling
-				dba::update('contact', ['last-update' => Temporal::utcNow()], ['id' => $contact['id']]);
+				dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
 				Contact::markForArchival($contact);
 				return;
 			}
@@ -355,7 +356,7 @@ class OnePoll
 				unset($password);
 				logger("Mail: Connect to " . $mailconf['user']);
 				if ($mbox) {
-					$fields = ['last_check' => Temporal::utcNow()];
+					$fields = ['last_check' => DateTimeFormat::utcNow()];
 					dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
 					logger("Mail: Connected to " . $mailconf['user']);
 				} else {
@@ -395,7 +396,7 @@ class OnePoll
 								// Only delete when mails aren't automatically moved or deleted
 								if (($mailconf['action'] != 1) && ($mailconf['action'] != 3))
 									if ($meta->deleted && ! $item['deleted']) {
-										$fields = ['deleted' => true, 'changed' => Temporal::utcNow()];
+										$fields = ['deleted' => true, 'changed' => DateTimeFormat::utcNow()];
 										dba::update('item', $fields, ['id' => $item['id']]);
 									}
 
@@ -459,7 +460,7 @@ class OnePoll
 							$datarray['title'] = notags(trim($datarray['title']));
 
 							//$datarray['title'] = notags(trim($meta->subject));
-							$datarray['created'] = Temporal::utc($meta->date);
+							$datarray['created'] = DateTimeFormat::utc($meta->date);
 
 							// Is it a reply?
 							$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") ||
@@ -572,7 +573,7 @@ class OnePoll
 			if (!strstr($xml, '<')) {
 				logger('post_handshake: response from ' . $url . ' did not contain XML.');
 
-				$fields = ['last-update' => Temporal::utcNow(), 'failure_update' => Temporal::utcNow()];
+				$fields = ['last-update' => DateTimeFormat::utcNow(), 'failure_update' => DateTimeFormat::utcNow()];
 				self::updateContact($contact, $fields);
 				Contact::markForArchival($contact);
 				return;
@@ -616,19 +617,19 @@ class OnePoll
 				}
 			}
 
-			$updated = Temporal::utcNow();
+			$updated = DateTimeFormat::utcNow();
 
 			self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
 			dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::unmarkForArchival($contact);
 		} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
-			$updated = Temporal::utcNow();
+			$updated = DateTimeFormat::utcNow();
 
 			self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
 			dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
 			Contact::markForArchival($contact);
 		} else {
-			$updated = Temporal::utcNow();
+			$updated = DateTimeFormat::utcNow();
 			dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
 		}
 
diff --git a/src/Worker/UpdateGContact.php b/src/Worker/UpdateGContact.php
index da307b4fa..98a62818e 100644
--- a/src/Worker/UpdateGContact.php
+++ b/src/Worker/UpdateGContact.php
@@ -9,7 +9,7 @@ namespace Friendica\Worker;
 use Friendica\Database\DBM;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 
 class UpdateGContact
 {
@@ -42,7 +42,7 @@ class UpdateGContact
 			}
 
 			q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `id` = %d",
-				dbesc(Temporal::utcNow()), intval($contact_id));
+				dbesc(DateTimeFormat::utcNow()), intval($contact_id));
 			return;
 		}
 

From 5518ef2fb4893b15fbe9b1fa6e0dfcc7c8d66403 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Fri, 26 Jan 2018 21:43:43 -0500
Subject: [PATCH 17/24] Fix include/boot uses

---
 boot.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot.php b/boot.php
index 59ab52552..a699a66f9 100644
--- a/boot.php
+++ b/boot.php
@@ -22,6 +22,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'a
 use Friendica\App;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
+use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -29,7 +30,6 @@ use Friendica\Database\DBM;
 use Friendica\Database\DBStructure;
 use Friendica\Model\Contact;
 use Friendica\Util\DateTimeFormat;
-use Friendida\Core\L10n;
 
 require_once 'include/text.php';
 require_once 'include/datetime.php';

From bb5670016e73858919c1d5521fe8c8183e3f0ab4 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Sat, 27 Jan 2018 08:11:49 -0500
Subject: [PATCH 18/24] Fix wrong self references in Util\Temporal

---
 src/Util/Temporal.php | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php
index e04165069..311a750cf 100644
--- a/src/Util/Temporal.php
+++ b/src/Util/Temporal.php
@@ -132,7 +132,7 @@ class Temporal
 		if ($dob < '0000-01-01') {
 			$value = '';
 		} else {
-			$value = self::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"]) : "");
@@ -368,11 +368,11 @@ class Temporal
 			$viewer_tz = date_default_timezone_get();
 		}
 
-		$birthdate = self::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d');
+		$birthdate = DateTimeFormat::convert($dob . ' 00:00:00+00:00', $owner_tz, 'UTC', 'Y-m-d');
 		list($year, $month, $day) = explode("-", $birthdate);
-		$year_diff = self::timezoneNow($viewer_tz, 'Y') - $year;
-		$curr_month = self::timezoneNow($viewer_tz, 'm');
-		$curr_day = self::timezoneNow($viewer_tz, 'd');
+		$year_diff  = DateTimeFormat::timezoneNow($viewer_tz, 'Y') - $year;
+		$curr_month = DateTimeFormat::timezoneNow($viewer_tz, 'm');
+		$curr_day   = DateTimeFormat::timezoneNow($viewer_tz, 'd');
 
 		if (($curr_month < $month) || (($curr_month == $month) && ($curr_day < $day))) {
 			$year_diff--;
@@ -412,7 +412,7 @@ class Temporal
 	{
 		$d = sprintf('%04d-%02d-01 00:00', intval($y), intval($m));
 
-		return self::utc($d, 'w');
+		return DateTimeFormat::utc($d, 'w');
 	}
 
 	/**
@@ -442,8 +442,8 @@ class Temporal
 			'October', 'November', 'December'
 		];
 
-		$thisyear = self::localNow('Y');
-		$thismonth = self::localNow('m');
+		$thisyear = DateTimeFormat::localNow('Y');
+		$thismonth = DateTimeFormat::localNow('m');
 		if (!$y) {
 			$y = $thisyear;
 		}
@@ -460,7 +460,7 @@ class Temporal
 		$started = false;
 
 		if (($y == $thisyear) && ($m == $thismonth)) {
-			$tddate = intval(self::localNow('j'));
+			$tddate = intval(DateTimeFormat::localNow('j'));
 		}
 
 		$str_month = day_translate($mtab[$m]);

From 0454d0a670e051e8519e9a4220606f83d1408214 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Sun, 28 Jan 2018 13:28:22 -0500
Subject: [PATCH 19/24] Fix incorrect Temporal reference after Item function
 move rebase

---
 src/Model/Item.php | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/Model/Item.php b/src/Model/Item.php
index 818c4085f..7ba6a42e9 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -302,11 +302,11 @@ class Item extends BaseObject
 		$arr['owner-name']    = trim(defaults($arr, 'owner-name', ''));
 		$arr['owner-link']    = trim(defaults($arr, 'owner-link', ''));
 		$arr['owner-avatar']  = trim(defaults($arr, 'owner-avatar', ''));
-		$arr['received']      = ((x($arr, 'received') !== false) ? Temporal::convert($arr['received']) : Temporal::convert());
-		$arr['created']       = ((x($arr, 'created') !== false) ? Temporal::convert($arr['created']) : $arr['received']);
-		$arr['edited']        = ((x($arr, 'edited') !== false) ? Temporal::convert($arr['edited']) : $arr['created']);
-		$arr['changed']       = ((x($arr, 'changed') !== false) ? Temporal::convert($arr['changed']) : $arr['created']);
-		$arr['commented']     = ((x($arr, 'commented') !== false) ? Temporal::convert($arr['commented']) : $arr['created']);
+		$arr['received']      = ((x($arr, 'received') !== false) ? DateTimeFormat::utc($arr['received']) : DateTimeFormat::utcNow());
+		$arr['created']       = ((x($arr, 'created') !== false) ? DateTimeFormat::utc($arr['created']) : $arr['received']);
+		$arr['edited']        = ((x($arr, 'edited') !== false) ? DateTimeFormat::utc($arr['edited']) : $arr['created']);
+		$arr['changed']       = ((x($arr, 'changed') !== false) ? DateTimeFormat::utc($arr['changed']) : $arr['created']);
+		$arr['commented']     = ((x($arr, 'commented') !== false) ? DateTimeFormat::utc($arr['commented']) : $arr['created']);
 		$arr['title']         = trim(defaults($arr, 'title', ''));
 		$arr['location']      = trim(defaults($arr, 'location', ''));
 		$arr['coord']         = trim(defaults($arr, 'coord', ''));
@@ -342,13 +342,13 @@ class Item extends BaseObject
 		}
 
 		// Items cannot be stored before they happen ...
-		if ($arr['created'] > Temporal::convert()) {
-			$arr['created'] = Temporal::convert();
+		if ($arr['created'] > DateTimeFormat::utcNow()) {
+			$arr['created'] = DateTimeFormat::utcNow();
 		}
 
 		// We haven't invented time travel by now.
-		if ($arr['edited'] > Temporal::convert()) {
-			$arr['edited'] = Temporal::convert();
+		if ($arr['edited'] > DateTimeFormat::utcNow()) {
+			$arr['edited'] = DateTimeFormat::utcNow();
 		}
 
 		if (($arr['author-link'] == "") && ($arr['owner-link'] == "")) {
@@ -742,9 +742,9 @@ class Item extends BaseObject
 		// update the commented timestamp on the parent
 		// Only update "commented" if it is really a comment
 		if (($arr['verb'] == ACTIVITY_POST) || !Config::get("system", "like_no_comment")) {
-			dba::update('item', ['commented' => Temporal::convert(), 'changed' => Temporal::convert()], ['id' => $parent_id]);
+			dba::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
 		} else {
-			dba::update('item', ['changed' => Temporal::convert()], ['id' => $parent_id]);
+			dba::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
 		}
 
 		if ($dsprsig) {
@@ -1644,7 +1644,7 @@ class Item extends BaseObject
 			intval($wall ? 1 : 0)
 		);
 		if (DBM::is_result($r)) {
-			return substr(Temporal::convert($r[0]['created'], date_default_timezone_get()),0,10);
+			return substr(DateTimeFormat::local($r[0]['created']),0,10);
 		}
 		return false;
 	}

From 59a5b13d2aef40dea4c57aa99ae9a40e236a2ac2 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Thu, 1 Feb 2018 04:25:56 -0500
Subject: [PATCH 20/24] Remove stray semicolon in Util\Temporal

---
 src/Util/Temporal.php | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php
index 311a750cf..5451bdf49 100644
--- a/src/Util/Temporal.php
+++ b/src/Util/Temporal.php
@@ -395,7 +395,6 @@ class Temporal
 	public static function getDaysInMonth($y, $m)
 	{
 		return date('t', mktime(0, 0, 0, $m, 1, $y));
-		;
 	}
 
 	/**

From 593774b613937652e9cb245cc064f7dc50ecdffe Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Fri, 2 Feb 2018 14:34:41 -0500
Subject: [PATCH 21/24] Update moved method Item::performLike() with
 DateTypeFormat

- Update use list
---
 src/Model/Item.php | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/Model/Item.php b/src/Model/Item.php
index 7ba6a42e9..d83546e34 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -23,7 +23,6 @@ use Friendica\Object\Image;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Temporal;
 use dba;
 use Text_LanguageDetect;
 
@@ -1776,7 +1775,7 @@ class Item extends BaseObject
 			$like_item = $existing_like[0];
 
 			// Already voted, undo it
-			$fields = ['deleted' => true, 'unseen' => true, 'changed' => datetime_convert()];
+			$fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
 			dba::update('item', $fields, ['id' => $like_item['id']]);
 
 			// Clean up the Diaspora signatures for this like

From 7f5af05d251a22b6a39458bf0ada5ac1b0078597 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Sat, 3 Feb 2018 09:51:05 -0500
Subject: [PATCH 22/24] Fix wrong default format for default date in mod/events

---
 mod/events.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mod/events.php b/mod/events.php
index 7637486f8..4f45c61bf 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -469,15 +469,15 @@ function events_content(App $a) {
 		$smonth = DateTimeFormat::convert($sdt, $tz, 'UTC', 'm');
 		$sday   = DateTimeFormat::convert($sdt, $tz, 'UTC', 'd');
 
-		$shour   = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : 0);
-		$sminute = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : 0);
+		$shour   = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'H') : '00');
+		$sminute = ((x($orig_event)) ? DateTimeFormat::convert($sdt, $tz, 'UTC', 'i') : '00');
 
 		$fyear  = DateTimeFormat::convert($fdt, $tz, 'UTC', 'Y');
 		$fmonth = DateTimeFormat::convert($fdt, $tz, 'UTC', 'm');
 		$fday   = DateTimeFormat::convert($fdt, $tz, 'UTC', 'd');
 
-		$fhour   = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : 0);
-		$fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : 0);
+		$fhour   = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'H') : '00');
+		$fminute = ((x($orig_event)) ? DateTimeFormat::convert($fdt, $tz, 'UTC', 'i') : '00');
 
 		require_once 'include/acl_selectors.php' ;
 

From 1e99cea03317ef7185aab7553cc576bc4d4e1931 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan 
Date: Sat, 3 Feb 2018 09:51:23 -0500
Subject: [PATCH 23/24] [frio] Fix spacing in field_input.tpl

---
 view/theme/frio/templates/field_input.tpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/view/theme/frio/templates/field_input.tpl b/view/theme/frio/templates/field_input.tpl
index c7b0bbfb2..bbd7535e5 100644
--- a/view/theme/frio/templates/field_input.tpl
+++ b/view/theme/frio/templates/field_input.tpl
@@ -1,7 +1,7 @@
 
 
- + {{$field.3}}
From 5cca8562bc8b57ca1d511014b3d2ea0ee208b9e8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 3 Feb 2018 09:53:45 -0500 Subject: [PATCH 24/24] Move datetimepicker javascript to field_datetime.tpl - Add type hint to getDateTimeField() arguments --- src/Util/Temporal.php | 82 +++++++++++++------------------ view/templates/field_datetime.tpl | 35 +++++++++++++ 2 files changed, 69 insertions(+), 48 deletions(-) create mode 100644 view/templates/field_datetime.tpl diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 5451bdf49..e200d9073 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -185,23 +185,32 @@ class Temporal /** * @brief Returns a datetime selector. * - * @param string $min Unix timestamp of minimum date - * @param string $max Unix timestamp of maximum date - * @param string $default Unix timestamp of default date - * @param string $id Id and name of datetimepicker (defaults to "datetimepicker") - * @param bool $pickdate true to show date picker (default) - * @param bool $picktime true to show time picker (default) - * @param string $minfrom set minimum date from picker with id $minfrom (none by default) - * @param string $maxfrom set maximum date from picker with id $maxfrom (none by default) - * @param bool $required default false + * @param DateTime $minDate Minimum date + * @param DateTime $maxDate Maximum date + * @param DateTime $defaultDate Default date + * @param string $id Id and name of datetimepicker (defaults to "datetimepicker") + * @param bool $pickdate true to show date picker (default) + * @param bool $picktime true to show time picker (default) + * @param string $minfrom set minimum date from picker with id $minfrom (none by default) + * @param string $maxfrom set maximum date from picker with id $maxfrom (none by default) + * @param bool $required default false * * @return string Parsed HTML output. * * @todo Once browser support is better this could probably be replaced with * native HTML5 date picker. */ - public static function getDateTimeField($min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, - $picktime = true, $minfrom = '', $maxfrom = '', $required = false) + public static function getDateTimeField( + DateTime $minDate, + DateTime $maxDate, + DateTime $defaultDate, + $label, + $id = 'datetimepicker', + $pickdate = true, + $picktime = true, + $minfrom = '', + $maxfrom = '', + $required = false) { // First day of the week (0 = Sunday) $firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0); @@ -230,41 +239,12 @@ class Temporal $dateformat .= 'H:i'; } - $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; - $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; + $input_text = $defaultDate ? date($dateformat, $defaultDate->getTimestamp()) : ''; - $input_text = $default ? date($dateformat, $default->getTimestamp()) : ''; - $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; + $readable_format = str_replace(['Y', 'm', 'd', 'H', 'i'], ['yyyy', 'mm', 'dd', 'HH', 'MM'], $dateformat); - $pickers = ''; - if (!$pickdate) { - $pickers .= ', datepicker: false'; - } - - if (!$picktime) { - $pickers .= ',timepicker: false'; - } - - $extra_js = ''; - $pickers .= ",dayOfWeekStart: " . $firstDay . ",lang:'" . $lang . "'"; - if ($minfrom != '') { - $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; - } - - if ($maxfrom != '') { - $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; - } - - $readable_format = $dateformat; - $readable_format = str_replace('Y', 'yyyy', $readable_format); - $readable_format = str_replace('m', 'mm', $readable_format); - $readable_format = str_replace('d', 'dd', $readable_format); - $readable_format = str_replace('H', 'HH', $readable_format); - $readable_format = str_replace('i', 'MM', $readable_format); - - $tpl = get_markup_template('field_input.tpl'); - $o .= replace_macros($tpl, - [ + $tpl = get_markup_template('field_datetime.tpl'); + $o .= replace_macros($tpl, [ '$field' => [ $id, $label, @@ -273,12 +253,18 @@ class Temporal $required ? '*' : '', 'placeholder="' . $readable_format . '"' ], + '$datetimepicker' => [ + 'minDate' => $minDate, + 'maxDate' => $maxDate, + 'defaultDate' => $defaultDate, + 'dateformat' => $dateformat, + 'firstDay' => $firstDay, + 'lang' => $lang, + 'minfrom' => $minfrom, + 'maxfrom' => $maxfrom, + ] ]); - $o .= ""; - return $o; } diff --git a/view/templates/field_datetime.tpl b/view/templates/field_datetime.tpl new file mode 100644 index 000000000..6b3431672 --- /dev/null +++ b/view/templates/field_datetime.tpl @@ -0,0 +1,35 @@ +{{include file='field_input.tpl' field=$field}}