phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.datetime.inc.php,1.5.2.1,1.5.


From: Mark A Peters <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.datetime.inc.php,1.5.2.1,1.5.2.2
Date: Sun, 23 Jun 2002 14:04:34 -0400

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv3409

Modified Files:
      Tag: Version-0_9_14-branch
        class.datetime.inc.php 
Log Message:
A more enahanced datetime class.  This one will store the server's TZ offset in 
the cache and use that value to calculate GMT.

Index: class.datetime.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.datetime.inc.php,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -C2 -r1.5.2.1 -r1.5.2.2
*** class.datetime.inc.php      16 Apr 2002 15:41:40 -0000      1.5.2.1
--- class.datetime.inc.php      23 Jun 2002 18:04:31 -0000      1.5.2.2
***************
*** 46,64 ****
                var $tz_offset;
                var $days = Array();
!               var $gmtnow;
!               var $gmtdate;
  
                function datetime()
                {
!                       $this->tz_offset = ((60 * 60) * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
! /*
!  * This is not advanced enough to automatically recalc Daylight Savings time
!                       if(date('I') == 1)
                        {
!                               $this->tz_offset += 3600;
                        }
!  */
!                       $this->gmtdate = gmdate('D, d M Y H:i:s',time()).' GMT';
!                       $this->gmtnow = 
$this->convert_rfc_to_epoch($this->gmtdate);
                }
  
--- 46,126 ----
                var $tz_offset;
                var $days = Array();
!               var $gmtnow = 0;
!               var $users_localtime
!               var $cv_gmtdate;
  
                function datetime()
                {
!                       $this->tz_offset = 3600 * 
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']);
! //                    echo '<!-- datetime::datetime::gmtnow = 
'.$this->gmtnow.' -->'."\n";
! 
!                       $error_occured = True;
!                       // If we already have a GMT time, no need to do this 
again.
!                       if(!$this->gmtnow && 
address@hidden($GLOBALS['phpgw_info']['server']['tz_offset']))
!                       {
! //                            echo '<!-- datetime::datetime::debug: Inside 
network time -->'."\n";            
!                               $error_occured = False;
!                               if(address@hidden($GLOBALS['phpgw']->network))
!                               {
!                                       $GLOBALS['phpgw']->network = 
createobject('phpgwapi.network');
!                               }
!                               $server_time = time();
!                               
if($GLOBALS['phpgw']->network->open_port('129.6.15.28',13,15))
!                               {
!                                       $line = 
$GLOBALS['phpgw']->network->bs_read_port(64);
!                                       // Value returned is 52384 02-04-20 
13:55:29 50 0 0   9.2 UTC(NIST) *
!                                       
$GLOBALS['phpgw']->network->close_port();
!                               
!                                       $array = explode(' ',$line);
!                                       
!                                       if ($array[5] == 4)
!                                       {
!                                               $error_occured = True;
!                                       }
!                                       else
!                                       {
!                                               $date = explode('-',$array[1]);
!                                               $time = explode(':',$array[2]);
!                                               $this->gmtnow = 
mktime(intval($time[0]),intval($time[1]),intval($time[2]),intval($date[1]),intval($date[2]),intval($date[0])
 + 2000);
!                                       }
!                               }
!                       }
!                       
elseif(isset($GLOBALS['phpgw_info']['server']['tz_offset']))
!                       {
! //                            echo '<!-- datetime::datetime::debug: Inside 
server already set -->'."\n";              
!                               $error_occured = False;
!                               $this->gmtnow = time() - 
(intval($GLOBALS['phpgw_info']['server']['tz_offset']) * 3600);
!                       }
!                       else
!                       {
!                               $error_occured = True;
!                       }
! 
!                       if($error_occured)
!                       {
! //                            echo '<!-- datetime::datetime::debug: Inside 
getting from local server -->'."\n";               
!                               $server_time = time();
!                               // Calculate GMT time...
!                               // If DST, add 1 hour...
!                               //  - (date('I') == 1?3600:0)
!                               $this->gmtnow = 
$this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s',$server_time).' GMT');
!                       }
! 
!                       
if(address@hidden($GLOBALS['phpgw_info']['server']['tz_offset']))
                        {
!                               $GLOBALS['phpgw_info']['server']['tz_offset'] = 
(($server_time - $this->gmtnow) / 3600);
!                               
if(@isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info']))
!                               {
!                                       $cache_query = "DELETE FROM 
phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and 
location='config'";
!                                       
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);                   
        
!                                       $cache_query = 'INSERT INTO 
phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
!                                               . 
"'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')";
!                                       
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
!                               }
                        }
!                       $this->users_localtime = $this->gmtnow - 
$this->tz_offset;
! //                    echo '<!-- datetime::datetime::tz_offset = 
'.$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'].' 
-->'."\n";
! //                    echo '<!-- datetime::datetime::server:tz_offset = 
'.$GLOBALS['phpgw_info']['server']['tz_offset'].' -->'."\n";
! //                    echo '<!-- datetime::datetime::gmtnow = 
'.$this->gmtnow.' -->'."\n";
                }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]