diff --git a/index.html b/index.html index 1e1e1ac..d90f91f 100644 --- a/index.html +++ b/index.html @@ -109,6 +109,12 @@ jQuery.timeago(new Date()); //=> "& jQuery.timeago("2008-07-17"); //=> "" jQuery.timeago(jQuery("abbr#some_id")); //=> "" // [title="2008-07-20"] +

+ To support timestamps in the future, use the allowFuture setting: +

+
+jQuery.timeago.settings.allowFuture = true;
+

Where?

Download the "stable" release.

diff --git a/jquery.timeago.js b/jquery.timeago.js index 3171688..b88c41f 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -1,5 +1,5 @@ /* - * timeago: a jQuery plugin, version: 0.3.2.99 (07/30/2008) + * timeago: a jQuery plugin, version: 0.4 (08/05/2008) * @requires jQuery v1.2 or later * * Timeago is a jQuery plugin that makes it easy to support automatically @@ -22,9 +22,16 @@ $.extend($.timeago, { settings: { - refreshMillis: 60000 + refreshMillis: 60000, + allowFuture: false }, inWords: function(distanceMillis) { + var suffix = " ago"; + if (this.settings.allowFuture) { + if (distanceMillis < 0) suffix = " from now"; + distanceMillis = Math.abs(distanceMillis); + } + var seconds = distanceMillis / 1000; var minutes = seconds / 60; var hours = minutes / 60; @@ -43,7 +50,7 @@ years < 2 && "about a year" || Math.floor(years) + " years"; - return words + " ago"; + return words + suffix; }, parse: function(iso8601) { var s = $.trim(iso8601); diff --git a/test.html b/test.html index 9d71f8e..d30a536 100644 --- a/test.html +++ b/test.html @@ -8,6 +8,7 @@