Ticket #8081: i18n_pretty_timedelta.patch
| File i18n_pretty_timedelta.patch, 1.5 KB (added by anonymous, 3 years ago) |
|---|
-
trac/util/datefmt.py
25 25 26 26 from trac.core import TracError 27 27 from trac.util.text import to_unicode 28 from trac.util.translation import _, tag_, N_, gettext 28 29 29 30 # Date/time utilities 30 31 … … 72 73 time2 = to_datetime(time2) 73 74 if time1 > time2: 74 75 time2, time1 = time1, time2 75 units = ((3600 * 24 * 365, 'year', 'years'),76 (3600 * 24 * 30, 'month', 'months'),77 (3600 * 24 * 7, 'week', 'weeks'),78 (3600 * 24, 'day', 'days'),79 (3600, 'hour', 'hours'),80 (60, 'minute', 'minutes'))76 units = ((3600 * 24 * 365, _('year'), _('years')), 77 (3600 * 24 * 30, _('month'), _('months')), 78 (3600 * 24 * 7, _('week'), _('weeks')), 79 (3600 * 24, _('day'), _('days')), 80 (3600, _('hour'), _('hours')), 81 (60, _('minute'), _('minutes'))) 81 82 diff = time2 - time1 82 83 age_s = int(diff.days * 86400 + diff.seconds) 83 84 if resolution and age_s < resolution: 84 85 return '' 85 86 if age_s <= 60 * 1.9: 86 return '%i second%s' % (age_s, age_s != 1 and 's' or '')87 return '%i %s' % (age_s, age_s == 1 and _('second') or _('seconds')) 87 88 for u, unit, unit_plural in units: 88 89 r = float(age_s) / float(u) 89 90 if r >= 1.9:
