Use getter/setter for timezone value
This commit is contained in:
parent
40a42ccdb1
commit
866dbf9f89
|
@ -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 ++;
|
||||
|
|
23
src/App.php
23
src/App.php
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue