Changeset 2446
- Timestamp:
- 07/10/07 11:03:31 (1 year ago)
- Files:
-
- worklogplugin/0.10/worklog/timeline_hook.py (modified) (1 diff)
- worklogplugin/0.10/worklog/uihooks_ticket.py (modified) (2 diffs)
- worklogplugin/0.10/worklog/util.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
worklogplugin/0.10/worklog/timeline_hook.py
r2424 r2446 46 46 previous_update = None 47 47 for user,ticket,time,starttime,kind,humankind,summary in cursor: 48 summary = Markup.escape(summary) 48 49 ticket_href = href.ticket(ticket) 49 50 if format == 'rss': 50 title = '%s %s working on Ticket #%s: %s' % \51 (user, humankind, ticket, summary)51 title = Markup('%s %s working on Ticket #%s (%s)' % \ 52 (user, humankind, ticket, summary)) 52 53 else: 53 54 title = Markup('%s %s working on Ticket <em title="%s">#%s</em>' % \ worklogplugin/0.10/worklog/uihooks_ticket.py
r2433 r2446 43 43 li_task.appendChild(a);""" 44 44 45 timedelta = pretty_timedelta(datetime.fromtimestamp(task['starttime']), None , True);45 timedelta = pretty_timedelta(datetime.fromtimestamp(task['starttime']), None); 46 46 script += """ 47 47 li_task.appendChild(document.createTextNode(' for """ + timedelta + """'));""" … … 50 50 51 51 def get_ticket_js(self, who, since): 52 timedelta = pretty_timedelta(datetime.fromtimestamp(since), None , True);52 timedelta = pretty_timedelta(datetime.fromtimestamp(since), None); 53 53 script = """ 54 54 li_tctk = document.createElement('li'); worklogplugin/0.10/worklog/util.py
r2424 r2446 2 2 3 3 # Stolen from Trac trunk :) 4 def pretty_timedelta(time1, time2=None , full=False):4 def pretty_timedelta(time1, time2=None): 5 5 """Calculate time delta (inaccurately, only for decorative purposes ;-) for 6 6 prettyprinting. If time1 is None, the current time is used.""" … … 18 18 age_s = int(diff.days * 86400 + diff.seconds) 19 19 if age_s < 60: 20 return ' %i second%s' % (age_s, age_s != 1 and 's' or '')20 return 'less than a minute' 21 21 rv = '' 22 22 for u, unit, unit_plural in units: 23 r = float(age_s) / float(u) 24 if r >= 0.9: 25 r = int(round(r)) 23 r = int(float(age_s) / float(u)) 24 if r > 0: 26 25 tmp_rv = '%d %s' % (r, r == 1 and unit or unit_plural) 27 if not full:28 return tmp_rv29 26 if rv: 30 27 rv += ', ' 31 28 rv += tmp_rv 32 age_s = float(age_s) - (r * float(u))29 age_s = float(age_s) - (r * float(u)) 33 30 return rv 34 31
