Fixes issue with relative dates in JS
authorMatthias Schmidt <gravatronics@live.com>
Thu, 13 Jun 2013 09:14:11 +0000 (11:14 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 13 Jun 2013 09:14:11 +0000 (11:14 +0200)
wcfsetup/install/files/js/WCF.js

index ccf76c519f38a326c6219d301ba94d9decce2c26..db67d0310b86ff5b195805f8af3e8a0764248132 100755 (executable)
@@ -2711,7 +2711,7 @@ WCF.Date.Util = {
        
        /**
         * Returns a Date object with precise offset (including timezone and local timezone).
-        * Parameter timestamp must be in miliseconds!
+        * Parameters timestamp and offset must be in miliseconds!
         * 
         * @param       integer         timestamp
         * @param       integer         offset
@@ -2719,9 +2719,9 @@ WCF.Date.Util = {
         */
        getTimezoneDate: function(timestamp, offset) {
                var $date = new Date(timestamp);
-               var $localOffset = $date.getTimezoneOffset() * -1 * 60000;
+               var $localOffset = $date.getTimezoneOffset() * 60000;
                
-               return new Date((timestamp - $localOffset - offset));
+               return new Date((timestamp + $localOffset + offset));
        }
 };
 
@@ -2833,7 +2833,7 @@ WCF.Date.Time = Class.extend({
                        var $days = Math.ceil(($midnight / 1000 - $timestamp) / 86400);
                        
                        // get day of week
-                       var $dateObj = WCF.Date.Util.getTimezoneDate(($timestamp * 1000), $offset);
+                       var $dateObj = WCF.Date.Util.getTimezoneDate(($timestamp * 1000), $offset * 1000);
                        var $dow = $dateObj.getDay();
                        var $day = WCF.Language.get('__days')[$dow];