From a16ab0f5037bf9f61e7c877d590abb8cdde4136c Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 31 Oct 2017 07:08:17 +0100 Subject: [PATCH] Fix Date/Util.getTimeElement() for future dates Close #2460 --- wcfsetup/install/files/js/WoltLabSuite/Core/Date/Util.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Util.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Util.js index 3dc51a2b7f..40be093072 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Util.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Util.js @@ -226,7 +226,7 @@ define(['Language'], function(Language) { * * Note: The actual content of the element is empty and is expected * to be automatically updated by `WoltLabSuite/Core/Date/Time/Relative` - * after the DOM change listener has been triggered. + * (for dates not in the future) after the DOM change listener has been triggered. * * @param {Date} date displayed date * @return {HTMLElement} `time` element @@ -235,6 +235,9 @@ define(['Language'], function(Language) { var time = elCreate('time'); time.classList = 'datetime'; + var formattedDate = this.formatDate(date); + var formattedTime = this.formatTime(date); + elAttr(time, 'datetime', this.format(date, 'c')); elData(time, 'timestamp', (date.getTime() - date.getMilliseconds()) / 1000); elData(time, 'date', this.formatDate(date)); @@ -243,6 +246,8 @@ define(['Language'], function(Language) { if (date.getTime() > new Date().getTime()) { elData(time, 'is-future-date', 'true'); + + time.textContent = Language.get('wcf.date.dateTimeFormat').replace('%time%', formattedTime).replace('%date%', formattedDate); } return time; -- 2.20.1