seaofclouds/tweet — Issue #222: 'Time of tweet' text strings could be more idiomatic
Author: baloneysandwiches
Created: 2012-03-07 19:59:41+00:00
State: open

First, at line 112, I find the "within the past second" window of time for something to qualify as "just now" to be really restrictive! Maybe I have a looser conception of time :) but this is so restrictive as to be almost never used. For my purpose I went with the past 20 seconds.

Second, if a tweet was in fact posted "just now", it currently winds up getting printed to the screen as "About just now", which sounds awkward.

Third, the "about" string feels weird when you're quantifying the exact number of seconds that have elapsed since the tweet. "About 43 seconds"? I dunno, that sounds pretty darn exact to me. I suggest bringing in the "about" string only for some of the longer durations. It sounds more idiomatic to me, personally.

Here is what I suggest to replace lines 112-130:

if (delta < 20) {
r = 'Just now ';
} else if (delta < 60) {
r = delta + ' seconds ago ';
} else if(delta < 120) {
r = 'About a minute ago ';
} else if(delta < (45*60)) {
r = 'About ' + (parseInt(delta / 60, 10)).toString() + ' minutes ago ';
} else if(delta < (2*60*60)) {
r = 'About an hour ago ';
} else if(delta < (24*60*60)) {
r = (parseInt(delta / 3600, 10)).toString() + ' hours ago ';
} else if(delta < (48*60*60)) {
r = 'A day ago ';
} else {
r = (parseInt(delta / 86400, 10)).toString() + ' days ago ';
}
return r;
}