aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2013-01-03 20:18:28 +0100
committerMarcin Kuzminski <marcin@python-works.com>2013-01-03 20:18:28 +0100
commite1f48a7325dfe03e6c14c060fb0691fe2ab3ea9c (patch)
tree26e74c01fa36eacca2287617c30aebccb96087f5
parent339b4a3383065ddebfb7ecb9bd281e1fc02c28b7 (diff)
fixed bad date calculations
--HG-- branch : beta
-rw-r--r--rhodecode/tests/test_libs.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/rhodecode/tests/test_libs.py b/rhodecode/tests/test_libs.py
index b0482aef..fe541081 100644
--- a/rhodecode/tests/test_libs.py
+++ b/rhodecode/tests/test_libs.py
@@ -123,15 +123,16 @@ class TestLibs(unittest.TestCase):
from rhodecode.lib.utils2 import age
n = datetime.datetime.now()
delt = lambda *args, **kwargs: datetime.timedelta(*args, **kwargs)
+ prev_month = n.month - 1 if n.month != 1 else n.month - 2
self.assertEqual(age(n), u'just now')
self.assertEqual(age(n - delt(seconds=1)), u'1 second ago')
self.assertEqual(age(n - delt(seconds=60 * 2)), u'2 minutes ago')
self.assertEqual(age(n - delt(hours=1)), u'1 hour ago')
self.assertEqual(age(n - delt(hours=24)), u'1 day ago')
self.assertEqual(age(n - delt(hours=24 * 5)), u'5 days ago')
- self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month - 1]))),
+ self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[prev_month]))),
u'1 month ago')
- self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[n.month - 1] + 2))),
+ self.assertEqual(age(n - delt(hours=24 * (calendar.mdays[prev_month] + 2))),
u'1 month and 2 days ago')
self.assertEqual(age(n - delt(hours=24 * 400)), u'1 year and 1 month ago')