""" Create an astrodatetime object from a Python datetime object""" return astrodatetime(datetimeObj.year, datetimeObj.month, datetimeObj.day, datetimeObj.hour, datetimeObj.minute, datetimeObj.second, datetimeObj.microsecond, tzinfo=datetimeObj.tzinfo) # Have to put this here to deal with circular imports import convert if __name__ == "__main__": # Functional and unit tests import unittest, sys, math jd = 2455893.68753 mjd = convert.jdToMJD(jd) y = 2011 m = 11 d = 28 hr,min,seconds = convert.hoursToHMS(convert.parseHours("04:30:02.6")) sf, sec = math.modf(seconds) class TestAstrodatetime(unittest.TestCase): def test_jd(self): dt = astrodatetime.fromJD(jd) self.assertEqual(y, dt.year) self.assertEqual(m, dt.month) self.assertEqual(d, dt.day) self.assertEqual(hr, dt.hour) self.assertEqual(min, dt.minute) self.assertEqual(sec, dt.second) self.assertAlmostEqual(sf, dt.microsecond/1.E6, 1) def test_mjd(self): dt = astrodatetime.fromMJD(mjd)
def hms(self): """ Returns the angle's value in hours, and print as an (h,m,s) tuple (read-only property). """ return convert.hoursToHMS(convert.radiansToHours(self.radians))