service.py

changeset 42
0b53b7c70875
parent 38
d0ae1996abdd
child 48
428cfdf64ccc
equal deleted inserted replaced
41:4354d459c231 42:0b53b7c70875
105 tr = tr, 105 tr = tr,
106 ) 106 )
107 107
108 def time_representation(time, relative = True): 108 def time_representation(time, relative = True):
109 time_difference = time - now() 109 time_difference = time - now()
110 if relative and time_difference > timedelta(0) and time_difference < timedelta(minutes = 1): 110 if relative and timedelta(minutes = -1) < time_difference < timedelta(minutes = 1):
111 return tr('right-now', 'misc-text') 111 return tr('right-now', 'misc-text')
112 elif relative and time_difference > timedelta(0) and time_difference < timedelta(minutes = 10): 112 elif relative and time_difference > timedelta(0) and time_difference < timedelta(minutes = 10):
113 return '%dm' % round(time_difference.seconds / 60) 113 return '%dm' % round(time_difference.seconds / 60)
114 elif time.date() == today(): 114 elif time.date() == today():
115 return '%d:%02d' % (time.hour, time.minute) 115 return '%d:%02d' % (time.hour, time.minute)

mercurial