def test_github_issue1_cal_day(self): # https://github.com/brandon-rhodes/python-novas/pull/1 # The cal_date() routine was always raising ArgumentError year, month, day, hour = novas.cal_date(jd) self.assertEqual(year, 2008) self.assertEqual(month, 4) self.assertEqual(day, 24) self.assertAlmostEqual(hour, 10.605000000447035, 15)
def test_cal_date(): for jd in 0.0, 2414988.5, 2415020.31352, 2442249.5, 2456335.2428472: assert c.cal_date(jd) == timescales.cal_date(jd)
def shorter_cal_date(jd): y, m, d, h = novas.cal_date(jd) return y, m, d + h / 24.0 - 0.5
def jdutc2bt(jd_utc): t = novas.cal_date(jd_utc + 8 / 24) a = int(t[3]) b = int((t[3] - a) * 60) c = (t[3] - a - b / 60.0) * 3600.0 return (t, a, b, c)
def test_cal_date(): for jd in 0.0, 2414988.5, 2415020.31352, 2442249.5, 2456335.2428472: whole, fraction = divmod((jd + 0.5), 1.0) y, m, d = timelib.calendar_date(int(whole)) assert c.cal_date(jd) == (y, m, d, 24.0 * fraction)