Skip to content

Commit

Permalink
Handle the (rare) case when tweets with future times appear (fixes se…
Browse files Browse the repository at this point in the history
…aofclouds#190)

If the client's machine clock is running slow, tweets may appear to
come from the future, and thus display "-20 seconds ago". In this
case, we instead display "just now".
  • Loading branch information
purcell committed Nov 11, 2011
1 parent 3e70b97 commit 1037663
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tweet/jquery.tweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
var delta = parseInt((relative_to.getTime() - date) / 1000, 10);
var r = '';
if (delta < 60) {
if (delta < 1) {
r = 'just now';
} else if (delta < 60) {
r = delta + ' seconds ago';
} else if(delta < 120) {
r = 'a minute ago';
Expand Down

0 comments on commit 1037663

Please sign in to comment.