Python: Implemented MakeTime function.

This commit is contained in:
Don Cross
2019-06-22 21:33:48 -04:00
parent 66b0efda5a
commit f29d44aa43
2 changed files with 26 additions and 0 deletions

View File

@@ -258,3 +258,16 @@ def CurrentTime():
dt = now - _EPOCH
ut = dt.total_seconds() / 86400.0
return astro_time_t(ut)
def MakeTime(year, month, day, hour, minute, second):
# This formula is adapted from NOVAS C 3.1 function julian_date().
jd12h = (
day - 32075 + 1461 * (year + 4800
+ (month - 14) / 12) / 4
+ 367 * (month - 2 - (month - 14) / 12 * 12)
/ 12 - 3 * ((year + 4900 + (month - 14) / 12)
/ 100) / 4)
y2000 = jd12h - 2451545
ut = y2000 - 0.5 + (hour / 24.0) + (minute / (24.0 * 60.0)) + (second / (24.0 * 3600.0))
return astro_time_t(ut)