X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/7390a7a0721d9985c88efec1fd0e3a19d0368c82..77598dfa9fccb668345198ea169cf7cf00b9845e:/underlays/javascript/relativedate.js?ds=sidebyside diff --git a/underlays/javascript/relativedate.js b/underlays/javascript/relativedate.js index c5e62b3cc..5142332f1 100644 --- a/underlays/javascript/relativedate.js +++ b/underlays/javascript/relativedate.js @@ -1,4 +1,4 @@ -// Causes html elements in the 'date' and 'pagedate' classes to be displayed +// Causes html elements in the 'relativedate' class to be displayed // as relative dates. The date is parsed from the title attribute, or from // the element content. @@ -7,7 +7,7 @@ var dateElements; hook("onload", getDates); function getDates() { - dateElements = getElementsByClass('date'); + dateElements = getElementsByClass('relativedate'); for (var i = 0; i < dateElements.length; i++) { var elt = dateElements[i]; var title = elt.attributes.title; @@ -45,6 +45,12 @@ function relativeDate(date) { var offset = date.getTime() - now.getTime(); var seconds = Math.round(Math.abs(offset) / 1000); + // hack to avoid reading just in the future if there is a minor + // amount of clock slip + if (offset >= 0 && seconds < 30 * timeUnits['minute']) { + return "just now"; + } + var ret = ""; var shown = 0; for (i = 0; i < timeUnitOrder.length; i++) {