Tweak sdate script to print correct Julian date

The existing script was rounding the computed Julian date which was
resulting in the script printing the next day for 12 hours in the day,
i.e., a date of 456314.5 was being printed as 45631.5 (due to the
division by 10 and rounding up by the print statement). Now, the script
computes the number of days since the epoch (JD 2000000) and drops the
fractional portion, so it will print the correct Julian date stardate,
i.e., a date of 456314.5 will be printed correctly as 45631.4.
vimbundler
nirenjan 2013-01-21 16:51:46 -08:00
parent e6b3a404fa
commit d348aef645
1 changed files with 3 additions and 2 deletions

View File

@ -2,14 +2,15 @@
""" Calculate the Julian Date """
import time
import math
t = time.time()
""" Technically, we should be adding 2440587.5,
however, since we are trying to stick to the stardate
concept, we add only 440587.5"""
jd = t / 86400.0 + 440587.5
jd = math.floor(t / 86400.0 + 440587.5)
# Use the idea that 10 Julian days is equal to 1 stardate
print "%05.1f" % (jd / 10)
print "%05.1f" % (jd / 10.0)