From 6bfc97da869ca180d2f5fee01c9ff503cb47b1bd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 26 Apr 2013 10:31:57 +0400 Subject: add automatic timezone (based on client tz offset) --- include/functions.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'include/functions.php') diff --git a/include/functions.php b/include/functions.php index b54187e18..4272c649d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -862,13 +862,18 @@ $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid); - try { - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); - } catch (Exception $e) { - $user_tz = $utc_tz; - } + if ($user_tz_string != 'Automatic') { - $tz_offset = $user_tz->getOffset($dt); + try { + if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); + } catch (Exception $e) { + $user_tz = $utc_tz; + } + + $tz_offset = $user_tz->getOffset($dt); + } else { + $tz_offset = (int) $_SESSION["clientTzOffset"]; + } $user_timestamp = $dt->format('U') + $tz_offset; -- cgit v1.2.3