do not store tz offset in global, store timezone object instead
This commit is contained in:
parent
dcd7ecaa0f
commit
5ddef5ba23
1 changed files with 10 additions and 13 deletions
|
@ -125,8 +125,6 @@
|
||||||
|
|
||||||
require_once 'lib/pubsubhubbub/publisher.php';
|
require_once 'lib/pubsubhubbub/publisher.php';
|
||||||
|
|
||||||
$tz_offset = -1;
|
|
||||||
$utc_tz = new DateTimeZone('UTC');
|
|
||||||
$schema_version = false;
|
$schema_version = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -853,26 +851,25 @@
|
||||||
if (!$timestamp) $timestamp = '1970-01-01 0:00';
|
if (!$timestamp) $timestamp = '1970-01-01 0:00';
|
||||||
|
|
||||||
global $utc_tz;
|
global $utc_tz;
|
||||||
global $tz_offset;
|
global $user_tz;
|
||||||
|
|
||||||
|
if (!$utc_tz) $utc_tz = new DateTimeZone('UTC');
|
||||||
|
|
||||||
$timestamp = substr($timestamp, 0, 19);
|
$timestamp = substr($timestamp, 0, 19);
|
||||||
|
|
||||||
# We store date in UTC internally
|
# We store date in UTC internally
|
||||||
$dt = new DateTime($timestamp, $utc_tz);
|
$dt = new DateTime($timestamp, $utc_tz);
|
||||||
|
|
||||||
if ($tz_offset == -1) {
|
$user_tz_string = get_pref('USER_TIMEZONE', $owner_uid);
|
||||||
|
|
||||||
$user_tz_string = get_pref('USER_TIMEZONE', $owner_uid);
|
try {
|
||||||
|
if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string);
|
||||||
try {
|
} catch (Exception $e) {
|
||||||
$user_tz = new DateTimeZone($user_tz_string);
|
$user_tz = $utc_tz;
|
||||||
} catch (Exception $e) {
|
|
||||||
$user_tz = $utc_tz;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tz_offset = $user_tz->getOffset($dt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tz_offset = $user_tz->getOffset($dt);
|
||||||
|
|
||||||
$user_timestamp = $dt->format('U') + $tz_offset;
|
$user_timestamp = $dt->format('U') + $tz_offset;
|
||||||
|
|
||||||
if (!$no_smart_dt) {
|
if (!$no_smart_dt) {
|
||||||
|
|
Loading…
Reference in a new issue