[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [21198] Improvement: use timezone rather than offset
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] [21198] Improvement: use timezone rather than offset 4746:5203 |
Date: |
Wed, 14 Apr 2010 19:29:51 +0000 |
Revision: 21198
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=21198
Author: sigurdne
Date: 2010-04-14 19:29:51 +0000 (Wed, 14 Apr 2010)
Log Message:
-----------
Improvement: use timezone rather than offset 4746:5203
Modified Paths:
--------------
people/sigurdne/modules/phpgwapi/trunk/inc/class.preferences.inc.php
Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.preferences.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.preferences.inc.php
2010-04-14 19:29:11 UTC (rev 21197)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.preferences.inc.php
2010-04-14 19:29:51 UTC (rev 21198)
@@ -333,6 +333,22 @@
if (is_array($this->data))
{
reset($this->data);
+
+ // This one should cope with daylight saving
time
+ // Create two timezone objects, one for UTC
(GMT) and one for
+ // user pref
+ $dateTimeZone_utc = new DateTimeZone('UTC');
+ $dateTimeZone_pref = new
DateTimeZone(isset($this->data['common']['timezone']) &&
$this->data['common']['timezone'] ? $this->data['common']['timezone'] : 'UTC');
+
+ // Create two DateTime objects that will
contain the same Unix timestamp, but
+ // have different timezones attached to them.
+ $dateTime_utc = new DateTime("now",
$dateTimeZone_utc);
+ $dateTime_pref = new DateTime("now",
$dateTimeZone_pref);
+
+ // Calculate the GMT offset for the date/time
contained in the $dateTime_utc
+ // object, but using the timezone rules as
defined for Tokyo
+
+ $this->data['common']['tz_offset'] =
(int)$dateTimeZone_pref->getOffset($dateTime_utc)/3600;
}
if ($this->debug &&
substr($GLOBALS['phpgw_info']['flags']['currentapp'],0,3) != 'log')
{
@@ -341,6 +357,7 @@
echo "default<pre>"; print_r($this->default);
echo "</pre>\n";
echo "effectiv<pre>";print_r($this->data); echo
"</pre>\n";
}
+
return $this->data;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [21198] Improvement: use timezone rather than offset 4746:5203,
Sigurd Nes <=