]> git.mxchange.org Git - friendica.git/blobdiff - mod/ping.php
Add Temporal::timezoneNow() shorthand for Temporal::convert()
[friendica.git] / mod / ping.php
index 6e11e18cd6ea5584a7b4726fe227004474298eb8..d26fc61befecf57c0bd7fd8815ed0896a459eaa9 100644 (file)
@@ -2,16 +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\System;
+use Friendica\Core\L10n;
 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';
@@ -222,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::utc('now + 7 days')),
+                               dbesc(Temporal::utcNow())
                        );
                        if (DBM::is_result($ev)) {
                                Cache::set($cachekey, $ev, CACHE_HOUR);
@@ -234,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::timezoneNow($a->timezone, 'Y-m-d');
                                foreach ($ev as $x) {
                                        $bd = false;
                                        if ($x['type'] === 'birthday') {
@@ -243,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 ++;
@@ -286,7 +289,7 @@ function ping_init(App $a)
                                        'photo'   => $intro['photo'],
                                        'date'    => $intro['datetime'],
                                        'seen'    => false,
-                                       'message' => t('{0} wants to be your friend'),
+                                       'message' => L10n::t('{0} wants to be your friend'),
                                ];
                                $notifs[] = $notif;
                        }
@@ -301,7 +304,7 @@ function ping_init(App $a)
                                        'photo'   => $mail['from-photo'],
                                        'date'    => $mail['created'],
                                        'seen'    => false,
-                                       'message' => t('{0} sent you a message'),
+                                       'message' => L10n::t('{0} sent you a message'),
                                ];
                                $notifs[] = $notif;
                        }
@@ -316,7 +319,7 @@ function ping_init(App $a)
                                        'photo'   => $reg['micro'],
                                        'date'    => $reg['created'],
                                        'seen'    => false,
-                                       'message' => t('{0} requested registration'),
+                                       'message' => L10n::t('{0} requested registration'),
                                ];
                                $notifs[] = $notif;
                        }
@@ -359,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'],