Properly handle dates in the future
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 20 Oct 2012 16:09:43 +0000 (18:09 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 20 Oct 2012 16:09:43 +0000 (18:09 +0200)
wcfsetup/install/files/js/WCF.js

index 7f9249beec4318f999d7cb009e81b97377a14abf..8a830769595077ca4c91cf4285929bd01ba85d5a 100755 (executable)
@@ -2077,8 +2077,13 @@ WCF.Date.Time.prototype = {
                var $time = $(element).data('time');
                var $offset = $(element).data('offset');
                
+               // timestamp is in the future
+               if ($timestamp > this.timestamp) {
+                       var $string = WCF.Language.get('wcf.date.dateTimeFormat');
+                       $(element).text($string.replace(/\%date\%/, $date).replace(/\%time\%/, $time));
+               }
                // timestamp is less than 60 minutes ago (display 1 hour ago rather than 60 minutes ago)
-               if (this.timestamp < ($timestamp + 3540)) {
+               else if (this.timestamp < ($timestamp + 3540)) {
                        var $minutes = Math.round((this.timestamp - $timestamp) / 60);
                        $(element).text(eval(WCF.Language.get('wcf.date.relative.minutes')));
                }