def test_datetime(self): "DateTime.__init__() with DateTime parameter copies attributes" self.assertEquals( chrono.DateTime(chrono.DateTime("2009-12-27 16:27:43")).get(), (2009, 12, 27, 16, 27, 43) )
def test_date(self): "DateTime.__ne__() handles Date objects" self.assertTrue( chrono.DateTime("2009-12-27 16:27:43") != chrono.Date("2009-12-27") ) self.assertFalse( chrono.DateTime("2009-12-27 00:00:00") != chrono.Date("2009-12-27") )
def test_string(self): "DateTime.__eq__() handles strings" self.assertTrue( chrono.DateTime("2009-12-27 16:27:43") == "2009-12-27 16:27:43" ) self.assertFalse( chrono.DateTime("2010-07-23 16:27:43") == "2010-07-22 16:27:43" )
def test_string(self): "DateTime.__ne__() handles strings" self.assertTrue( chrono.DateTime("2009-12-27 16:27:43") != "2009-12-26 16:27:43" ) self.assertFalse( chrono.DateTime("2009-12-27 16:27:43") != "2009-12-27 16:27:43" )
def test_datetime(self): "Date.__gt__() handles DateTime objects" self.assertTrue( chrono.Date("2009-12-28") > chrono.DateTime("2009-12-27 16:27:43")) self.assertFalse( chrono.Date("2009-12-28") > chrono.DateTime("2009-12-28 00:00:00")) self.assertFalse( chrono.Date("2009-12-28") > chrono.DateTime("2009-12-28 16:27:43"))
def test_datetime(self): "DateTime.__eq__() handles DateTime objects" self.assertTrue( chrono.DateTime("2009-12-27 16:27:43") == \ chrono.DateTime("2009-12-27 16:27:43") ) self.assertFalse( chrono.DateTime("2009-12-27 16:27:43") == \ chrono.DateTime("2009-12-28 16:27:43") )
def test_datetime(self): "Date.__le__() handles DateTime objects" self.assertTrue( chrono.Date("2009-12-26") <= chrono.DateTime("2009-12-26 00:00:00") ) self.assertTrue( chrono.Date("2009-12-26") <= chrono.DateTime("2009-12-26 16:27:43") ) self.assertFalse( chrono.Date("2009-12-27") <= chrono.DateTime("2009-12-26 16:26:43") )
def test_second_overflow_doubleminute(self): "DateTime.__setattr__() handles double rollover for second overflow" d = chrono.DateTime("2010-07-23 16:27:43") d.second += 120 self.assertEquals(d.get(), (2010, 7, 23, 16, 29, 43))
def test_second_overflow(self): "DateTime.__setattr__() handles minute rollover for second overflow" d = chrono.DateTime("2010-07-23 16:27:43") d.second += 45 self.assertEquals(d.get(), (2010, 7, 23, 16, 28, 28))
def test_minute_overflow(self): "DateTime.__setattr__() handles hour rollover for minute overflow" d = chrono.DateTime("2010-07-23 16:27:43") d.minute += 45 self.assertEquals(d.get(), (2010, 7, 23, 17, 12, 43))
def test_string(self): "DateTime.get_string() returns date string" self.assertEquals( chrono.DateTime("2009-12-27 16:27:43").get_string(), "2009-12-27 16:27:43" )
def test_get(self): "DateTime.get() returns tuple of all attributes" self.assertEquals( chrono.DateTime("2009-12-27 16:27:43").get(), (2009, 12, 27, 16, 27, 43) )
def test_str(self): "DateTime.__str__() returns iso date" self.assertEquals( str(chrono.DateTime("2009-12-27 16:27:43")), "2009-12-27 16:27:43" )
def test_month_overflow(self): "DateTime.__setattr__() handles year rollover for month overflow" d = chrono.DateTime("2009-07-15 16:27:43") d.month += 10 self.assertEquals(d.get(), (2010, 5, 15, 16, 27, 43))
def test_month_negative_leap(self): "DateTime.__setattr__() handles leap years for negative months" d = chrono.DateTime("2008-02-29 16:27:43") d.month -= 12 self.assertEquals(d.get(), (2007, 3, 1, 16, 27, 43))
def test_month_negative_doublemonth(self): "DateTime.__setattr__() handles double rollunder for negative months" d = chrono.DateTime("2009-07-15 16:27:43") d.month -= 30 self.assertEquals(d.get(), (2007, 1, 15, 16, 27, 43))
def test_month_negative(self): "DateTime.__setattr__() handles year rollunder for negative months" d = chrono.DateTime("2009-04-15 16:27:43") d.month -= 6 self.assertEquals(d.get(), (2008, 10, 15, 16, 27, 43))
def test_month_dayoverflow(self): "DateTime.__setattr__() handles days outside new month range" d = chrono.DateTime("2009-07-31 16:27:43") d.month -= 1 self.assertEquals(d.get(), (2009, 7, 1, 16, 27, 43))
def test_minute_overflow_doublehour(self): "DateTime.__setattr__() handles double rollover for minute overflow" d = chrono.DateTime("2010-07-23 16:27:43") d.minute += 120 self.assertEquals(d.get(), (2010, 7, 23, 18, 27, 43))
def test_second_overflow_hour(self): "DateTime.__setattr__() handles hour rollover for second overflow" d = chrono.DateTime("2010-07-23 16:27:43") d.second += 3600 self.assertEquals(d.get(), (2010, 7, 23, 17, 27, 43))
def test_year_leap(self): "DateTime.__setattr__() handles leap years when changing year" d = chrono.DateTime("2008-02-29 16:27:43") d.year = 2009 self.assertEquals(d.get(), (2009, 3, 1, 16, 27, 43))
def test_month_overflow_doubleyear(self): "DateTime.__setattr__() handles double rollover for month overflow" d = chrono.DateTime("2009-03-15 16:27:43") d.month += 30 self.assertEquals(d.get(), (2011, 9, 15, 16, 27, 43))
def test_partial(self): "DateTime.assert_set() raises NoDateTimeError on partial date" d = chrono.DateTime("2010-07-23 16:27:43") d.day = None self.assertRaises(chrono.error.NoDateTimeError, d.assert_set)
def test_month_overflow_leap(self): "DateTime.__setattr__() handles leap years for month overflow" d = chrono.DateTime("2008-02-29 16:27:43") d.month += 12 self.assertEquals(d.get(), (2009, 3, 1, 16, 27, 43))
def test_get(self): "DateTime.get_julian() returns julian day" self.assertEquals( chrono.DateTime("2010-07-23 16:27:43").get_julian(), 2455401.6859143518518519 )
def test_second_negative_doubleminute(self): "DateTime.__setattr__() handles double rollunder for negative secs" d = chrono.DateTime("2010-07-23 16:27:43") d.second -= 120 self.assertEquals(d.get(), (2010, 7, 23, 16, 25, 43))
def test_partial(self): "DateTime.is_set() returns False if only some attributes are set" d = chrono.DateTime("2010-07-23 16:27:43") d.hour = None self.assertFalse(d.is_set())
def test_second_negative_hour(self): "DateTime.__setattr__() handles hour rollunder for negative seconds" d = chrono.DateTime("2010-07-23 16:27:43") d.second -= 1800 self.assertEquals(d.get(), (2010, 7, 23, 15, 57, 43))
def test_month_zero(self): "DateTime.__setattr__() handles rollunder for zero-months" d = chrono.DateTime("2008-06-21 16:27:43") d.month = 0 self.assertEquals(d.get(), (2007, 12, 21, 16, 27, 43))
def test_minute_negative_doublehour(self): "DateTime.__setattr__() handles double rollunder for negative minutes" d = chrono.DateTime("2010-07-23 16:27:43") d.minute -= 120 self.assertEquals(d.get(), (2010, 7, 23, 14, 27, 43))