
function humaneDate(date,compareTo){var lang={ago:'ago',now:'just now',minute:'minute',minutes:'minutes',hour:'hour',hours:'hours',day:'day',days:'days',week:'week',weeks:'weeks',month:'month',months:'months',year:'year',years:'years'},formats=[[60,lang.now],[3600,lang.minute,lang.minutes,60],[86400,lang.hour,lang.hours,3600],[604800,lang.day,lang.days,86400],[2628000,lang.week,lang.weeks,604800],[31536000,lang.month,lang.months,2628000],[Infinity,lang.year,lang.years,31536000]],isString=typeof date=='string',date=isString?new Date((''+date).replace(/-/g,"/").replace(/[TZ]/g," ")):date,compareTo=compareTo||new Date,seconds=(compareTo-date+
(compareTo.getTimezoneOffset()-
(isString?0:date.getTimezoneOffset()))*60000)/1000,token;if(seconds<0){seconds=Math.abs(seconds);token='';}else{token=' '+lang.ago;}
function normalize(val,single)
{var margin=0.1;if(val>=single&&val<=single*(1+margin)){return single;}
return val;}
for(var i=0,format=formats[0];formats[i];format=formats[++i]){if(seconds<format[0]){if(i===0){return format[1];}
var val=Math.ceil(normalize(seconds,format[3])/(format[3]));return val+' '+
(val!=1?format[2]:format[1])+
(i>0?token:'');}}};if(typeof jQuery!='undefined'){jQuery.fn.humaneDates=function()
{return this.each(function()
{var $t=jQuery(this),date=humaneDate($t.attr('title'));if(date&&$t.html()!=date){$t.html(date);}});};}
jQuery(document).ready(function(){jQuery('span.humaneDate').humaneDates();});

