Changeset 5285 in subversion


Ignore:
Timestamp:
Sep 28, 2011 7:49:37 AM (20 months ago)
Author:
thomasb
Message:

Distinguish standard timezone offset and DST of client

Location:
trunk/roundcubemail/program
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r5267 r5285  
    10391039    return ''; 
    10401040 
    1041   // get user's timezone 
     1041  // get user's timezone offset 
    10421042  $tz = $RCMAIL->config->get_timezone(); 
    10431043 
  • trunk/roundcubemail/program/include/rcmail.php

    r5264 r5285  
    898898      if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_') 
    899899        $_SESSION['timezone'] = floatval($_REQUEST['_timezone']); 
     900      if (isset($_REQUEST['_dstactive']) && $_REQUEST['_dstactive'] != '_default_') 
     901        $_SESSION['dst_active'] = intval($_REQUEST['_dstactive']); 
    900902 
    901903      // force reloading complete list of subscribed mailboxes 
  • trunk/roundcubemail/program/include/rcube_config.php

    r5132 r5285  
    9191        // enable display_errors in 'show' level, but not for ajax requests 
    9292        ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4))); 
     93         
     94        // set timezone auto settings values 
     95        if ($this->prop['timezone'] == 'auto') { 
     96          $this->prop['_timezone_auto'] = true; 
     97          $this->prop['dst_active'] = intval(date('I')); 
     98          $this->prop['timezone']   = date('Z') / 3600 - $this->prop['dst_active']; 
     99        } 
    93100 
    94101        // export config data 
     
    208215        $this->userprefs = $prefs; 
    209216        $this->prop      = array_merge($this->prop, $prefs); 
     217 
     218        // override timezone settings with client values 
     219        if ($this->prop['_timezone_auto']) { 
     220            $this->prop['timezone']   = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : $this->prop['timezone']; 
     221            $this->prop['dst_active'] = isset($_SESSION['dst_active']) ? $_SESSION['dst_active'] : $this->prop['dst_active']; 
     222        } 
    210223    } 
    211224 
     
    222235 
    223236    /** 
    224      * Special getter for user's timezone 
     237     * Special getter for user's timezone offset including DST 
     238     * 
     239     * @return float  Timezone offset (in hours) 
    225240     */ 
    226241    public function get_timezone() 
    227242    { 
    228       $tz = $this->get('timezone'); 
    229       if ($tz == 'auto') 
    230         $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z') / 3600; 
    231       else 
    232         $tz = intval($tz) + intval($this->get('dst_active')); 
    233  
    234       return $tz; 
     243      return floatval($this->get('timezone')) + intval($this->get('dst_active')); 
    235244    } 
    236245 
  • trunk/roundcubemail/program/include/rcube_template.php

    r5282 r5285  
    11061106        $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login')); 
    11071107        $input_tzone  = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_')); 
     1108        $input_dst    = new html_hiddenfield(array('name' => '_dstactive', 'id' => 'rcmlogindst', 'value' => '_default_')); 
    11081109        $input_url    = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url)); 
    11091110        $input_user   = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') 
     
    11571158        $out .= $input_action->show(); 
    11581159        $out .= $input_tzone->show(); 
     1160        $out .= $input_dst->show(); 
    11591161        $out .= $input_url->show(); 
    11601162        $out .= $table->show(); 
  • trunk/roundcubemail/program/js/app.js

    r5283 r5285  
    381381 
    382382        // detect client timezone 
    383         $('#rcmlogintz').val(new Date().getTimezoneOffset() / -60); 
     383        var tz = new Date().getTimezoneOffset() / -60; 
     384        var stdtz = new Date().getStdTimezoneOffset() / -60; 
     385        $('#rcmlogintz').val(stdtz); 
     386        $('#rcmlogindst').val(tz > stdtz ? 0 : 0); 
    384387 
    385388        // display 'loading' message on form submit, lock submit button 
  • trunk/roundcubemail/program/js/common.js

    r5280 r5285  
    672672}; 
    673673 
     674// Extend Date prototype to detect Standard timezone without DST 
     675// from http://www.michaelapproved.com/articles/timezone-detect-and-ignore-daylight-saving-time-dst/ 
     676Date.prototype.getStdTimezoneOffset = function() 
     677{ 
     678  var m = 12, 
     679    d = new Date(null, m, 1), 
     680    tzo = d.getTimezoneOffset(); 
     681 
     682    while (--m) { 
     683      d.setUTCMonth(m); 
     684      if (tzo != d.getTimezoneOffset()) { 
     685        return Math.max(tzo, d.getTimezoneOffset()); 
     686    } 
     687  } 
     688 
     689  return tzo; 
     690} 
    674691 
    675692// Make getElementById() case-sensitive on IE 
Note: See TracChangeset for help on using the changeset viewer.