Fixed future timestamps
authorMarcel Werk <burntime@woltlab.com>
Sun, 28 Apr 2013 14:34:04 +0000 (16:34 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 28 Apr 2013 14:34:04 +0000 (16:34 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/system/template/plugin/TimeModifierTemplatePlugin.class.php

index 9ade67bd2343d1d8d355394024d553d3132e1777..c9c64d58e3d435a3a2fca32873fae247e76b0f0a 100755 (executable)
@@ -2399,6 +2399,9 @@ WCF.Date.Time = Class.extend({
                var $time = $element.data('time');
                var $offset = $element.data('offset');
                
+               // skip for future dates
+               if ($element.data('isFutureDate')) return;
+               
                // timestamp is less than 60 minutes ago (display 1 hour ago rather than 60 minutes ago)
                if ($timestamp >= this._timestamp || this._timestamp < ($timestamp + 3540)) {
                        var $minutes = Math.max(Math.round((this._timestamp - $timestamp) / 60), 1);
index 2f4de6f2aa6771765dce1a717cc61785f8a7b5f5..677d7c4ddf37390f0f114be9af072cc39dbe6ce5 100644 (file)
@@ -30,6 +30,6 @@ class TimeModifierTemplatePlugin implements IModifierTemplatePlugin {
                $time = DateUtil::format($dateTimeObject, DateUtil::TIME_FORMAT);
                $dateTime = str_replace('%time%', $time, str_replace('%date%', $date, WCF::getLanguage()->get('wcf.date.dateTimeFormat')));
                
-               return '<time datetime="'.DateUtil::format($dateTimeObject, 'c').'" class="datetime" data-timestamp="'.$timestamp.'" data-date="'.$date.'" data-time="'.$time.'" data-offset="'.$dateTimeObject->getOffset().'">'.$dateTime.'</time>';
+               return '<time datetime="'.DateUtil::format($dateTimeObject, 'c').'" class="datetime" data-timestamp="'.$timestamp.'" data-date="'.$date.'" data-time="'.$time.'" data-offset="'.$dateTimeObject->getOffset().'"'.($timestamp > TIME_NOW ? ' data-is-future-date="true"' : '').'>'.$dateTime.'</time>';
        }
 }