]> git.mxchange.org Git - friendica.git/commitdiff
Use getter/setter for timezone value
authorMichael <heluecht@pirati.ca>
Sat, 24 Jul 2021 21:16:53 +0000 (21:16 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 24 Jul 2021 21:16:53 +0000 (21:16 +0000)
mod/ping.php
src/App.php
src/Model/Profile.php
src/Security/Authentication.php

index 146e7e75b57de6519d86adb0da61c11c33ad05c9..93c579e0a690a5d8edf994794ba3008148eba329 100644 (file)
@@ -230,7 +230,7 @@ function ping_init(App $a)
                        $all_events = count($ev);
 
                        if ($all_events) {
-                               $str_now = DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d');
+                               $str_now = DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d');
                                foreach ($ev as $x) {
                                        $bd = false;
                                        if ($x['type'] === 'birthday') {
@@ -239,7 +239,7 @@ function ping_init(App $a)
                                        } else {
                                                $events ++;
                                        }
-                                       if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) {
+                                       if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->getTimeZone() : 'UTC'), 'UTC', 'Y-m-d') === $str_now) {
                                                $all_events_today ++;
                                                if ($bd) {
                                                        $birthdays_today ++;
index e0fd2ef8fc193e8efc768541e4b9e50ae8ae7168..d71acef63221e5dc341f3be7633ff61dea02f2c1 100644 (file)
@@ -62,7 +62,6 @@ class App
        public $argv;
        /** @deprecated 2019.09 - use App\Arguments->getArgc() */
        public $argc;
-       public $timezone;
        public $theme_info = [];
        // Allow themes to control internal parameters
        // by changing App values in theme.php
@@ -72,6 +71,7 @@ class App
        public $theme_events_in_profile = true;
        public $queue;
 
+       private $timezone = '';
        private $profile_owner = 0;
        private $contact_id    = 0;
 
@@ -172,6 +172,27 @@ class App
                return $this->contact_id;
        }
 
+       /**
+        * Set the timezone
+        * 
+        * @param int $timezone 
+        * @return void 
+        */
+       public function setTimeZone(string $timezone)
+       {
+               $this->timezone = $timezone;
+       }
+
+       /**
+        * Get the timezone
+        *
+        * @return int 
+        */
+       public function getTimeZone():string
+       {
+               return $this->timezone;
+       }
+
        /**
         * Returns the current config cache of this node
         *
index 62df630dc8d5d5904cda6a0911b5238a19469b41..1c75201c9722f608fcb817843c50697b40a7d328 100644 (file)
@@ -544,7 +544,7 @@ class Profile
 
                                        $rr['link'] = Contact::magicLinkById($rr['cid']);
                                        $rr['title'] = $rr['name'];
-                                       $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
+                                       $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $a->getTimeZone(), 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
                                        $rr['startime'] = null;
                                        $rr['today'] = $today;
                                }
@@ -603,8 +603,8 @@ class Profile
                                        $total++;
                                }
 
-                               $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', 'Y-m-d');
-                               if ($strt === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
+                               $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC', 'UTC', 'Y-m-d');
+                               if ($strt === DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) {
                                        $istoday = true;
                                }
 
@@ -619,17 +619,17 @@ class Profile
                                        $description = DI::l10n()->t('[No description]');
                                }
 
-                               $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC');
+                               $strt = DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC');
 
-                               if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) {
+                               if (substr($strt, 0, 10) < DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) {
                                        continue;
                                }
 
-                               $today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d')) ? true : false);
+                               $today = ((substr($strt, 0, 10) === DateTimeFormat::timezoneNow($a->getTimeZone(), 'Y-m-d')) ? true : false);
 
                                $rr['title'] = $title;
                                $rr['description'] = $description;
-                               $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
+                               $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->getTimeZone() : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
                                $rr['startime'] = $strt;
                                $rr['today'] = $today;
 
index 3ad9a28999ae59819c45238b7f3821890744034e..d93f7f9dc5b6bd5cccf1cef7a150e232505b4cec 100644 (file)
@@ -307,7 +307,7 @@ class Authentication
 
                if (strlen($user_record['timezone'])) {
                        date_default_timezone_set($user_record['timezone']);
-                       $a->timezone = $user_record['timezone'];
+                       $a->setTimeZone($user_record['timezone']);
                }
 
                $contact = $this->dba->selectFirst('contact', ['id'], ['uid' => $user_record['uid'], 'self' => true]);