def test_same_month(self): fd = datetime(2007, 1, 1, 01, 00) cd = datetime(2007, 1, 3, 01, 00) self.assertEquals(dtformat(None, fd, cd), u'Added 2 days ago') cd = datetime(2007, 1, 4, 01, 00) self.assertEquals(dtformat(None, fd, cd), u'Added 3 days ago') # days and hours cd = datetime(2007, 1, 2, 02, 00) self.assertEquals( dtformat(None, fd, cd), u'Added one day, one hour ago') cd = datetime(2007, 1, 3, 03, 00) self.assertEquals( dtformat(None, fd, cd), u'Added 2 days, 2 hours ago') # days hours, minutes cd = datetime(2007, 1, 2, 02, 01) self.assertEquals( dtformat(None, fd, cd), 'Added one day, one hour ago') cd = datetime(2007, 1, 3, 03, 02) self.assertEquals( dtformat(None, fd, cd), u'Added 2 days, 2 hours ago') cd = datetime(2007, 1, 4, 04, 03) self.assertEquals( dtformat(None, fd, cd), u'Added 3 days, 3 hours ago') # weeks cd = datetime(2007, 1, 8, 01, 00) self.assertEquals(dtformat(None, fd, cd), u'Added one week ago') cd = datetime(2007, 1, 15, 01, 00) self.assertEquals(dtformat(None, fd, cd), u'Added 2 weeks ago')
def test_same_month(self): fd = datetime(2007, 1, 1, 0o1, 00) cd = datetime(2007, 1, 3, 0o1, 00) self.assertEquals(dtformat(None, fd, cd), 'Added 2 days ago') cd = datetime(2007, 1, 4, 0o1, 00) self.assertEquals(dtformat(None, fd, cd), 'Added 3 days ago') # days and hours cd = datetime(2007, 1, 2, 0o2, 00) self.assertEquals( dtformat(None, fd, cd), 'Added one day, one hour ago') cd = datetime(2007, 1, 3, 0o3, 00) self.assertEquals( dtformat(None, fd, cd), 'Added 2 days, 2 hours ago') # days hours, minutes cd = datetime(2007, 1, 2, 0o2, 0o1) self.assertEquals( dtformat(None, fd, cd), 'Added one day, one hour ago') cd = datetime(2007, 1, 3, 0o3, 0o2) self.assertEquals( dtformat(None, fd, cd), 'Added 2 days, 2 hours ago') cd = datetime(2007, 1, 4, 0o4, 0o3) self.assertEquals( dtformat(None, fd, cd), 'Added 3 days, 3 hours ago') # weeks cd = datetime(2007, 1, 8, 0o1, 00) self.assertEquals(dtformat(None, fd, cd), 'Added one week ago') cd = datetime(2007, 1, 15, 0o1, 00) self.assertEquals(dtformat(None, fd, cd), 'Added 2 weeks ago')
def test_different_month(self): fd = datetime(2007, 1, 1, 1, 00) cd = datetime(2007, 4, 4, 15, 0o6) self.assertEquals(dtformat(None, fd, cd), '2007-01-01 01:00:00')
def test_same_day(self): fd = datetime(2007, 1, 1, 0o1, 00) cd = datetime(2007, 1, 1, 0o1, 00) self.assertEquals(dtformat(None, fd, cd), 'Just added') # minutes cd = datetime(2007, 1, 1, 0o1, 0o1) self.assertEquals(dtformat(None, fd, cd), 'Added one minute ago') cd = datetime(2007, 1, 1, 0o1, 0o2) self.assertEquals(dtformat(None, fd, cd), 'Added 2 minutes ago') cd = datetime(2007, 1, 1, 0o1, 0o3) self.assertEquals(dtformat(None, fd, cd), 'Added 3 minutes ago') cd = datetime(2007, 1, 1, 0o1, 0o4) self.assertEquals(dtformat(None, fd, cd), 'Added 4 minutes ago') cd = datetime(2007, 1, 1, 0o1, 0o5) self.assertEquals(dtformat(None, fd, cd), 'Added 5 minutes ago') # hours cd = datetime(2007, 1, 1, 0o2, 00) self.assertEquals(dtformat(None, fd, cd), 'Added one hour ago') cd = datetime(2007, 1, 1, 0o3, 00) self.assertEquals(dtformat(None, fd, cd), 'Added 2 hours ago') # hours and minutes cd = datetime(2007, 1, 1, 0o2, 0o1) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, one minute ago') cd = datetime(2007, 1, 1, 0o2, 0o2) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, 2 minutes ago') cd = datetime(2007, 1, 1, 0o2, 0o3) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, 3 minutes ago') cd = datetime(2007, 1, 1, 0o2, 10) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, 10 minutes ago') cd = datetime(2007, 1, 1, 0o2, 11) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, 11 minutes ago') cd = datetime(2007, 1, 1, 0o2, 12) self.assertEquals( dtformat(None, fd, cd), 'Added one hour, 12 minutes ago') cd = datetime(2007, 1, 1, 0o3, 0o1) self.assertEquals( dtformat(None, fd, cd), 'Added 2 hours, one minute ago') cd = datetime(2007, 1, 1, 0o4, 0o5) self.assertEquals( dtformat(None, fd, cd), 'Added 3 hours, 5 minutes ago') cd = datetime(2007, 1, 2, 0o4, 10) self.assertEquals( dtformat(None, fd, cd), 'Added one day, 3 hours ago')
def test_different_month(self): fd = datetime(2007, 1, 1, 1, 00) cd = datetime(2007, 4, 4, 15, 06) self.assertEquals(dtformat(None, fd, cd), u'2007-01-01 01:00:00')
def test_same_day(self): fd = datetime(2007, 1, 1, 01, 00) cd = datetime(2007, 1, 1, 01, 00) self.assertEquals(dtformat(None, fd, cd), 'Just added') # minutes cd = datetime(2007, 1, 1, 01, 01) self.assertEquals(dtformat(None, fd, cd), u'Added one minute ago') cd = datetime(2007, 1, 1, 01, 02) self.assertEquals(dtformat(None, fd, cd), u'Added 2 minutes ago') cd = datetime(2007, 1, 1, 01, 03) self.assertEquals(dtformat(None, fd, cd), u'Added 3 minutes ago') cd = datetime(2007, 1, 1, 01, 04) self.assertEquals(dtformat(None, fd, cd), u'Added 4 minutes ago') cd = datetime(2007, 1, 1, 01, 05) self.assertEquals(dtformat(None, fd, cd), u'Added 5 minutes ago') # hours cd = datetime(2007, 1, 1, 02, 00) self.assertEquals(dtformat(None, fd, cd), u'Added one hour ago') cd = datetime(2007, 1, 1, 03, 00) self.assertEquals(dtformat(None, fd, cd), u'Added 2 hours ago') # hours and minutes cd = datetime(2007, 1, 1, 02, 01) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, one minute ago') cd = datetime(2007, 1, 1, 02, 02) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, 2 minutes ago') cd = datetime(2007, 1, 1, 02, 03) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, 3 minutes ago') cd = datetime(2007, 1, 1, 02, 10) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, 10 minutes ago') cd = datetime(2007, 1, 1, 02, 11) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, 11 minutes ago') cd = datetime(2007, 1, 1, 02, 12) self.assertEquals( dtformat(None, fd, cd), u'Added one hour, 12 minutes ago') cd = datetime(2007, 1, 1, 03, 01) self.assertEquals( dtformat(None, fd, cd), u'Added 2 hours, one minute ago') cd = datetime(2007, 1, 1, 04, 05) self.assertEquals( dtformat(None, fd, cd), u'Added 3 hours, 5 minutes ago') cd = datetime(2007, 1, 2, 04, 10) self.assertEquals( dtformat(None, fd, cd), u'Added one day, 3 hours ago')
def format_datetime(self, dt): return dtformat(self.request, dt, DateTime())