Python: added repr() support for astronomy.Time class.

Now when a Time object is evaluated and represented in
the Python interpreter, it results in a string of the form:

    astronomy.Time(ut)

where ut is the numeric representation of the ut field.
This mimics the exact way such a Time value could be constructed.
That is, eval(repr(t)) results in a time value equal to t.
This commit is contained in:
Don Cross
2020-05-05 21:40:55 -04:00
parent 6c3655c1c6
commit 107a07223b
2 changed files with 6 additions and 0 deletions

View File

@@ -553,6 +553,9 @@ class Time:
"""
return Time(self.ut + days)
def __repr__(self):
return 'astronomy.Time(' + repr(self.ut) + ')'
def __str__(self):
millis = round(self.ut * 86400000.0)
n = _EPOCH + datetime.timedelta(milliseconds=millis)