예제 #1
0
def test_ago():
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), '2 hours ago')
    d_str = (datetime.utcnow() - timedelta(hours=3)).isoformat()
    assert_equals(h.ago_string(d_str), '3 hours ago')
    assert_equals(h.ago_string('bad format'), 'unknown')
    assert_equals(h.ago_string(None), 'unknown')

    monthish = datetime.utcnow() - timedelta(days=32)
    assert 'ago' not in h.ago(monthish)
    assert_equals(h.ago(monthish, show_date_after=90), '1 month ago')
    assert_equals(h.ago(monthish, show_date_after=None), '1 month ago')
예제 #2
0
def test_ago():
    from datetime import datetime, timedelta
    import time

    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), "2 days ago")
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), "2 hours ago")
    d_str = (datetime.utcnow() - timedelta(hours=3)).isoformat()
    assert_equals(h.ago_string(d_str), "3 hours ago")
    assert_equals(h.ago_string("bad format"), "unknown")
    assert_equals(h.ago_string(None), "unknown")

    monthish = datetime.utcnow() - timedelta(days=32)
    assert "ago" not in h.ago(monthish)
    assert_equals(h.ago(monthish, show_date_after=90), "1 month ago")
    assert_equals(h.ago(monthish, show_date_after=None), "1 month ago")
예제 #3
0
def test_ago():
    from datetime import datetime, timedelta
    import time
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60 * 60 * 2), '2 hours ago')
예제 #4
0
 def time_since(self, *time_components):
     end_time = datetime(*time_components)
     with patch('allura.lib.helpers.datetime') as datetime_class:
         datetime_class.utcnow.return_value = end_time
         return helpers.ago(self.start_time)
예제 #5
0
 def time_since(self, *time_components):
     end_time = datetime(*time_components)
     with patch('allura.lib.helpers.datetime') as datetime_class:
         datetime_class.utcnow.return_value = end_time
         return helpers.ago(self.start_time)
예제 #6
0
 def summary(self):
     return '<a href="%s">%s</a> %s' % (
         self.author().url(), self.author().get_pref('display_name'),
         h.ago(self.timestamp))
예제 #7
0
def test_ago():
    from datetime import datetime, timedelta
    import time
    assert_equals(h.ago(datetime.utcnow() - timedelta(days=2)), '2 days ago')
    assert_equals(h.ago_ts(time.time() - 60*60*2), '2 hours ago')
예제 #8
0
 def summary(self):
     return '<a href="%s">%s</a> %s' % (
         self.author().url(), self.author().get_pref('display_name'),
         h.ago(self.timestamp))