mercurial/templatefilters.py
changeset 10601 b98b6a7363ae
parent 10282 08a0f04b56bd
child 10787 5974123d0339
equal deleted inserted replaced
10600:033d2fdc3b9d 10601:b98b6a7363ae
    12     '''turn nested template iterator into string.'''
    12     '''turn nested template iterator into string.'''
    13     if hasattr(thing, '__iter__') and not isinstance(thing, str):
    13     if hasattr(thing, '__iter__') and not isinstance(thing, str):
    14         return "".join([stringify(t) for t in thing if t is not None])
    14         return "".join([stringify(t) for t in thing if t is not None])
    15     return str(thing)
    15     return str(thing)
    16 
    16 
    17 agescales = [("second", 1),
    17 agescales = [("year", 3600 * 24 * 365),
       
    18              ("month", 3600 * 24 * 30),
       
    19              ("week", 3600 * 24 * 7),
       
    20              ("day", 3600 * 24),
       
    21              ("hour", 3600),
    18              ("minute", 60),
    22              ("minute", 60),
    19              ("hour", 3600),
    23              ("second", 1),]
    20              ("day", 3600 * 24),
       
    21              ("week", 3600 * 24 * 7),
       
    22              ("month", 3600 * 24 * 30),
       
    23              ("year", 3600 * 24 * 365)]
       
    24 
       
    25 agescales.reverse()
       
    26 
    24 
    27 def age(date):
    25 def age(date):
    28     '''turn a (timestamp, tzoff) tuple into an age string.'''
    26     '''turn a (timestamp, tzoff) tuple into an age string.'''
    29 
    27 
    30     def plural(t, c):
    28     def plural(t, c):