aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Smith <toonarmy@phpbb.com>2010-07-07 23:42:54 +0100
committerOleg Pudeyev <oleg@bsdpower.com>2012-03-14 22:57:30 -0400
commit1665434853fb09e70337d23955e1c9a5f3f0d19d (patch)
treea7b146dbed891e176954a302bdd0ee434e24d083
parentaf789040b8880f908df0a26d5239d07d77c34124 (diff)
downloadforums-1665434853fb09e70337d23955e1c9a5f3f0d19d.tar
forums-1665434853fb09e70337d23955e1c9a5f3f0d19d.tar.gz
forums-1665434853fb09e70337d23955e1c9a5f3f0d19d.tar.bz2
forums-1665434853fb09e70337d23955e1c9a5f3f0d19d.tar.xz
forums-1665434853fb09e70337d23955e1c9a5f3f0d19d.zip
[feature/new-tz-handling] Remove code using legacy timezone properties.
Code accessing the legacy user::$timezone and user::$dst properties has been removed and replaced with code utilising user::create_datetime(). Changed by Oleg: in viewtopic, memberlist and index use getTimestamp() + getOffset(). We show members that have birthdays on the specified date. getTimestamp() returns the current date in UTC. We add getOffset() to obtain the current local time in the viewing user's timezone. Then we find members having birthday on this date. Changed by Oleg again: Take leap year status out of the datetime object we have, this seems like it should work as one would expect. PHPBB3-9558
-rw-r--r--phpBB/feed.php2
-rw-r--r--phpBB/includes/functions_profile_fields.php9
-rw-r--r--phpBB/index.php5
-rw-r--r--phpBB/memberlist.php3
-rw-r--r--phpBB/viewtopic.php3
5 files changed, 14 insertions, 8 deletions
diff --git a/phpBB/feed.php b/phpBB/feed.php
index b8c0c370f9..d7092d6758 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -255,7 +255,7 @@ function feed_format_date($time)
{
global $user;
- $zone_offset = (int) $user->timezone + (int) $user->dst;
+ $zone_offset = $user->create_datetime()->getOffset();
$sign = ($zone_offset < 0) ? '-' : '+';
$time_offset = abs($zone_offset);
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index ec29a1732d..aacfa82c54 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -555,9 +555,12 @@ class custom_profile
else if ($day && $month && $year)
{
global $user;
- // Date should display as the same date for every user regardless of timezone, so remove offset
- // to compensate for the offset added by user::format_date()
- return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) - ($user->timezone + $user->dst), $user->lang['DATE_FORMAT'], true);
+ // Date should display as the same date for every user regardless of timezone
+
+ return $user->create_datetime()
+ ->setDate($year, $month, $day)
+ ->setTime(0, 0, 0)
+ ->format($user->lang['DATE_FORMAT'], true);
}
return $value;
diff --git a/phpBB/index.php b/phpBB/index.php
index 182efbc7e0..ccefd9833c 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -84,11 +84,12 @@ $legend = implode(', ', $legend);
$birthday_list = array();
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
- $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+ $time = $user->create_datetime();
+ $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
// Display birthdays of 29th february on 28th february in non-leap-years
$leap_year_birthdays = '';
- if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
+ if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
{
$leap_year_birthdays = " OR user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
}
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 556db2fa5d..ea8a6fc44b 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -1684,7 +1684,8 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
if ($bday_year)
{
- $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+ $now = $user->create_datetime();
+ $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index e78ba73cd7..782f02fd4b 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -965,7 +965,8 @@ $sql_ary = array(
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
-$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+$now = $user->create_datetime();
+$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
// Posts are stored in the $rowset array while $attach_list, $user_cache
// and the global bbcode_bitfield are built