def calc_age(date, trans=False):
 if trans:
  d = T('d')
  h = T('h')
  m = T('m')
 else:
  d = 'd'
  h = 'h'
  m = 'm'
 try:
  now = datetime.datetime.now()
  dage = (now - date)
  seconds = dage.seconds
  if dage.days:
   age = ('%s%s' % (dage.days, d))
  elif (seconds / 3600):
   age = ('%s%s' % ((seconds / 3600), h))
  else:
   age = ('%s%s' % ((seconds / 60), m))
 except:
  age = '-'
 return age

def calc_age ( date , trans = False ) : if trans : d = T ( 'd' ) h = T ( 'h' ) m = T ( 'm' ) else : d = 'd' h = 'h' m = 'm' try : now = datetime . datetime . now ( ) dage = ( now - date ) seconds = dage . seconds if dage . days : age = ( '%s%s' % ( dage . days , d ) ) elif ( seconds / 3600 ) : age = ( '%s%s' % ( ( seconds / 3600 ) , h ) ) else : age = ( '%s%s' % ( ( seconds / 60 ) , m ) ) except : age = '-' return age
calculate the age difference between now and date .