Mercurial > kallithea
changeset 653:4a3291628f09 beta
fixed a bug when age of last change is less than one minute
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 05 Nov 2010 16:49:29 +0100 |
parents | 0c065f793d0e |
children | 7f5976da192c |
files | rhodecode/lib/helpers.py |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Wed Nov 03 16:29:12 2010 +0100 +++ b/rhodecode/lib/helpers.py Fri Nov 05 16:49:29 2010 +0100 @@ -328,25 +328,25 @@ def _age(curdate): """turns a datetime into an age string.""" + if not curdate: return '' from datetime import timedelta, datetime agescales = [("year", 3600 * 24 * 365), - ("month", 3600 * 24 * 30), - #("week", 3600 * 24 * 7), - ("day", 3600 * 24), - ("hour", 3600), - ("minute", 60), - ("second", 1)] + ("month", 3600 * 24 * 30), + ("day", 3600 * 24), + ("hour", 3600), + ("minute", 60), + ("second", 1), ] age = datetime.now() - curdate age_seconds = (age.days * agescales[2][1]) + age.seconds - pos = 1 for scale in agescales: if scale[1] <= age_seconds: + if pos == 6:pos = 5 return time_ago_in_words(curdate, agescales[pos][0]) pos += 1