Show More
@@ -33,6 +33,7 b' fixes' | |||
|
33 | 33 | status. Checks now are made also for the repository. |
|
34 | 34 | - fixes #591 git backend was causing encoding errors when handling binary |
|
35 | 35 | files - added a test case for VCS lib tests |
|
36 | - fixed #597 commits in future get negative age. | |
|
36 | 37 | |
|
37 | 38 | 1.4.3 (**2012-09-28**) |
|
38 | 39 | ---------------------- |
@@ -314,9 +314,14 b' def age(prevdate):' | |||
|
314 | 314 | |
|
315 | 315 | order = ['year', 'month', 'day', 'hour', 'minute', 'second'] |
|
316 | 316 | deltas = {} |
|
317 | future = False | |
|
317 | 318 | |
|
318 | 319 | # Get date parts deltas |
|
319 | 320 | now = datetime.datetime.now() |
|
321 | if prevdate > now: | |
|
322 | now, prevdate = prevdate, now | |
|
323 | future = True | |
|
324 | ||
|
320 | 325 | for part in order: |
|
321 | 326 | deltas[part] = getattr(now, part) - getattr(prevdate, part) |
|
322 | 327 | |
@@ -369,10 +374,16 b' def age(prevdate):' | |||
|
369 | 374 | sub_value = 0 |
|
370 | 375 | |
|
371 | 376 | if sub_value == 0: |
|
372 | return _(u'%s ago') % fmt_funcs[part](value) | |
|
373 | ||
|
374 | return _(u'%s and %s ago') % (fmt_funcs[part](value), | |
|
375 |
fmt_funcs[ |
|
|
377 | if future: | |
|
378 | return _(u'in %s') % fmt_funcs[part](value) | |
|
379 | else: | |
|
380 | return _(u'%s ago') % fmt_funcs[part](value) | |
|
381 | if future: | |
|
382 | return _(u'in %s and %s') % (fmt_funcs[part](value), | |
|
383 | fmt_funcs[sub_part](sub_value)) | |
|
384 | else: | |
|
385 | return _(u'%s and %s ago') % (fmt_funcs[part](value), | |
|
386 | fmt_funcs[sub_part](sub_value)) | |
|
376 | 387 | |
|
377 | 388 | return _(u'just now') |
|
378 | 389 | |
@@ -504,4 +515,4 b' def obfuscate_url_pw(engine):' | |||
|
504 | 515 | url = url.make_url(engine) |
|
505 | 516 | if url.password: |
|
506 | 517 | url.password = 'XXXXX' |
|
507 | return str(url) No newline at end of file | |
|
518 | return str(url) |
@@ -129,10 +129,25 b' class TestLibs(unittest.TestCase):' | |||
|
129 | 129 | self.assertEqual(age(n - delt(hours=1)), u'1 hour ago') |
|
130 | 130 | self.assertEqual(age(n - delt(hours=24)), u'1 day ago') |
|
131 | 131 | self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago') |
|
132 | self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month-1] + 2))), | |
|
132 | self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month - 1] + 2))), | |
|
133 | 133 | u'1 month and 2 days ago') |
|
134 | 134 | self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago') |
|
135 | 135 | |
|
136 | def test_age_in_future(self): | |
|
137 | import calendar | |
|
138 | from rhodecode.lib.utils2 import age | |
|
139 | n = datetime.datetime.now() | |
|
140 | delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs) | |
|
141 | self.assertEqual(age(n), u'just now') | |
|
142 | self.assertEqual(age(n + delt(seconds=1)), u'in 1 second') | |
|
143 | self.assertEqual(age(n + delt(seconds=60 * 2)), u'in 2 minutes') | |
|
144 | self.assertEqual(age(n + delt(hours=1)), u'in 1 hour') | |
|
145 | self.assertEqual(age(n + delt(hours=24)), u'in 1 day') | |
|
146 | self.assertEqual(age(n + delt(hours=24 * 5)), u'in 5 days') | |
|
147 | self.assertEqual(age(n + delt(hours=24 * (calendar.mdays[n.month - 1] + 2))), | |
|
148 | u'in 1 month and 1 days') | |
|
149 | self.assertEqual(age(n + delt(hours=24 * 400)), u'in 1 year and 1 month') | |
|
150 | ||
|
136 | 151 | def test_tag_exctrator(self): |
|
137 | 152 | sample = ( |
|
138 | 153 | "hello pta[tag] gog [[]] [[] sda ero[or]d [me =>>< sa]" |
General Comments 0
You need to be logged in to leave comments.
Login now