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 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')