Beispiel #1
0
    def testYearFracFeb29_2(self):
        date1 = datetime.date(2000, 0o2, 29)
        date2 = datetime.date(2000, 0o3, 0o1)

        result = yearfrac(date1, date2)
        expected = 1 / 365.0
        self.assertEqual(expected, result)
Beispiel #2
0
    def testYearFracAlmostFullYear(self):

        date1 = datetime.date(2001, 0o1, 0o1)
        date2 = datetime.date(2001, 12, 31)
        result = yearfrac(date1, date2)
        expected = 364 / 365.0
        self.assertEqual(expected, result)
Beispiel #3
0
 def testYearFrac1Year(self):
     """Test a bunch of cases where the two dates are separated by 1 year"""
     for year in range(2000, 2020, 1):
         date1 = datetime.date(year, 1, 1)
         date2 = datetime.date(year + 1, 1, 1)
         result = yearfrac(date1, date2)
         self.assertEqual(1, result)
Beispiel #4
0
    def testYearFrac1000Years(self):
        date1 = datetime.date(2000, 0o1, 0o1)
        date2 = datetime.date(3000, 0o1, 0o1)

        result = yearfrac(date1, date2)
        expected = 1000
        self.assertEqual(expected, result)
Beispiel #5
0
    def testYearFrac(self):

        date1 = datetime.date(1987, 0o1, 12)
        date2 = datetime.date(1988, 12, 0o1)
        result = yearfrac(date1, date2)
        expected = 1.885245
        self.assertAlmostEqual(expected, result, 5)