/* aqStamp v1.0.5 Converts UNIX time stamps in seconds to human readable format. Copyright (C) 2011 paul pham This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ (function($) { $.aqStamp = function($sd, $title) { var _d = parseInt((new Date()).getTime() / 1000, 10) - parseInt($sd, 10), _string = '', _t = $.aqStamp.text; if (_d < 60) { _string = _t.seconds; } else if (_d < 120) { _string = _t.minute; } else if (_d < 3600) { _string = Math.round(_d / 60) + ' ' + _t.minutes; } else if (_d < 7200) { _string = _t.hour; } else if (_d < 86400) { _string = Math.round(_d / 3600) + ' ' + _t.hours; } else if (_d < 172800) { _string = _t.day; } else if (_d < 2678400) { _string = Math.round(_d / 86400) + ' ' + _t.days; } else if (_d < 5356800) { _string = _t.month; } else if (_d < 31536000) { _string = Math.round(_d / 2678400) + ' ' + _t.months; } else if (_d < 63072000) { _string = _t.year; } else { _string = Math.round(_d / 31536000) + ' ' + _t.years; } if ($title) { return '' + _string + ' ' + _t.ago + '<\/span>'; } return _string + ' ' + _t.ago; }; $.aqStamp.text = { seconds: 'few seconds', minute: 'about a minute', minutes: 'minutes', hour: 'over an hour', hours: 'hours', day: 'over a day', days: 'days', month: 'over a month', months: 'months', year: 'over a year', years: 'years', ago: 'ago' }; }(jQuery));