1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-14 04:30:29 +01:00

[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
This commit is contained in:
Chris Smith 2010-07-07 23:42:54 +01:00 committed by Oleg Pudeyev
parent af789040b8
commit 1665434853
5 changed files with 14 additions and 8 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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)) . "%'";
}

View File

@ -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)

View File

@ -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