mirror of https://github.com/nirenjan/dotfiles.git
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.master
parent
27c7871dfd
commit
1f76e13112
5
sdate
5
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue