def test_timesince(self): n = timezone.now() delta = [ ("days", 1 * 370), ("days", 200), ("days", 31), ("days", 30), ("days", 29), ("days", 8), ("days", 7), ("days", 6), ("hours", 5), ("minutes", 4), ("seconds", 61), ("seconds", 60), ("seconds", 3), ] for d in delta: print(timesince(n - timedelta(**dict([d]))))
def timesince(self, now=None): return timesince(self.timestamp, now)