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')
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")
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')
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)
def summary(self): return '<a href="%s">%s</a> %s' % ( self.author().url(), self.author().get_pref('display_name'), h.ago(self.timestamp))
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')