Show More
@@ -328,25 +328,25 from mercurial.templatefilters import pe | |||||
328 |
|
328 | |||
329 | def _age(curdate): |
|
329 | def _age(curdate): | |
330 | """turns a datetime into an age string.""" |
|
330 | """turns a datetime into an age string.""" | |
|
331 | ||||
331 | if not curdate: |
|
332 | if not curdate: | |
332 | return '' |
|
333 | return '' | |
333 |
|
334 | |||
334 | from datetime import timedelta, datetime |
|
335 | from datetime import timedelta, datetime | |
335 |
|
336 | |||
336 | agescales = [("year", 3600 * 24 * 365), |
|
337 | agescales = [("year", 3600 * 24 * 365), | |
337 | ("month", 3600 * 24 * 30), |
|
338 | ("month", 3600 * 24 * 30), | |
338 |
|
|
339 | ("day", 3600 * 24), | |
339 |
(" |
|
340 | ("hour", 3600), | |
340 |
(" |
|
341 | ("minute", 60), | |
341 |
(" |
|
342 | ("second", 1), ] | |
342 | ("second", 1)] |
|
|||
343 |
|
343 | |||
344 | age = datetime.now() - curdate |
|
344 | age = datetime.now() - curdate | |
345 | age_seconds = (age.days * agescales[2][1]) + age.seconds |
|
345 | age_seconds = (age.days * agescales[2][1]) + age.seconds | |
346 |
|
||||
347 | pos = 1 |
|
346 | pos = 1 | |
348 | for scale in agescales: |
|
347 | for scale in agescales: | |
349 | if scale[1] <= age_seconds: |
|
348 | if scale[1] <= age_seconds: | |
|
349 | if pos == 6:pos = 5 | |||
350 | return time_ago_in_words(curdate, agescales[pos][0]) |
|
350 | return time_ago_in_words(curdate, agescales[pos][0]) | |
351 | pos += 1 |
|
351 | pos += 1 | |
352 |
|
352 |
General Comments 0
You need to be logged in to leave comments.
Login now