# HG changeset patch # User Marcin Kuzminski # Date 1288972169 -3600 # Node ID 4a3291628f09fb78a92dc60ab433e5b5b8f02460 # Parent 0c065f793d0ee7ba0791b10bb5e5bf7e6873280e fixed a bug when age of last change is less than one minute diff -r 0c065f793d0e -r 4a3291628f09 rhodecode/lib/helpers.py --- 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