/**
* @exports WoltLab/WCF/Date/Time/Relative
*/
- var DateTimeRelative = {
+ return {
/**
* Transforms <time> elements on init and binds event listeners.
*/
if (!element.classList.contains('datetime') || elData(element, 'is-future-date')) continue;
- if (!element.getAttribute('title')) elAttr(element, 'title', element.textContent.trim());
-
var elTimestamp = ~~element.getAttribute('data-timestamp') + _offset;
var elDate = elData(element, 'date');
var elTime = elData(element, 'time');
var elOffset = elData(element, 'offset');
+ if (!element.getAttribute('title')) {
+ elAttr(element, 'title', Language.get('wcf.date.dateTimeFormat').replace(/%date%/, elDate).replace(/%time%/, elTime));
+ }
+
// timestamp is less than 60 seconds ago
if (elTimestamp >= timestamp || timestamp < (elTimestamp + 60)) {
element.textContent = Language.get('wcf.date.relative.now');
}
// timestamp is between ~700 million years BC and last week
else {
- element.textContent = Language.get('wcf.date.shortDateTimeFormat').replace(/\%date\%/, elDate).replace(/\%time\%/, elTime);
+ element.textContent = Language.get('wcf.date.shortDateTimeFormat').replace(/%date%/, elDate).replace(/%time%/, elTime);
}
}
}
};
-
- return DateTimeRelative;
});