Python: more work on date/time and formatting of same.

This commit is contained in:
Don Cross
2019-06-23 17:36:33 -04:00
parent 35017483cb
commit 8a344d251d
3 changed files with 20 additions and 2 deletions

View File

@@ -254,6 +254,11 @@ class astro_time_t:
def AddDays(self, days):
return astro_time_t(self.ut + days)
def __str__(self):
millis = round(self.ut * 86400000.0)
n = _EPOCH + datetime.timedelta(milliseconds=millis)
return '{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}.{:03d}Z'.format(n.year, n.month, n.day, n.hour, n.minute, n.second, math.floor(n.microsecond / 1000))
_EPOCH = datetime.datetime(2000, 1, 1, 12)
def CurrentTime():