mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user