From 1f76e1311235028b4c58ccae9db95ac2ea43cdfc Mon Sep 17 00:00:00 2001 From: nirenjan Date: Mon, 21 Jan 2013 16:51:46 -0800 Subject: [PATCH] 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. --- sdate | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdate b/sdate index 7426811..303d0ef 100755 --- a/sdate +++ b/sdate @@ -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)