The page http://www.leapsecond.com/java/gpsclock.htm contains interesting links about time.
### Julian days

First of all, dates are expressed in **Julian days**. Julian days express the number of days elapsed since January 1st, 4713 B.C. This is very interesting for computing, and all astronomical computations use this system, which was introduced in 1849 by John Herschel. See http://serendipity.magnet.ch/hermetic/cal_stud/jdn.htm for more details.
### Time transformations

You can find more detailed presentations of astronomical times at http://www.gb.nrao.edu/~rfisher/times.html or http://www.maa.mhn.de/Scholar/times.html.

When we want to compute an ephemeris, we enter a date expressed in **legal time**.

Applying a time zone offset, this time can be related to **UT** (Universal Time), the *civil* time at Greewhich.

**UT1**, the version of UT actually used, is based on the rotation of the Earth.

Earth rotation was used to measure the time. But it appeared that this rotation was not uniform. As more precision was needed, **ET**(Ephemeris Time) was defined, based on the revolution of the planets around the sun. In 1967, the official definition of the second became based on atomic pheomenon. From this, an other time could be defined : **TAI** (Temps Atomique International).

So why not measure our legal time with TAI? Because the time we feel is based on the rotation of the Earth. As time goes by, difference between TAI and UT1 grows.

**UTC** (Universal Time Coordinated) was invented to solve this problem :
UTC is based on TAI ;
UTC remains close to UT1 (UT1 - UTC < 0.9 second) ;
| **TAI - UTC = n**, n beeing an integer |
| (relation 1) |

This integer **n** cannot be predicted ; when people from the BIH (Bureau International de l'Heure) realize that Earth rotation has drifted from TAI, they decide that a second must be added to or dropped from UTC. See Below for details about computation of n.

UTC is used as the basis of legal time.

Planetary theories don't use TAI but an other time : **TDB** (Temps Dynamique Barycentrique), which permits to take relativistic effects into account.

To go from UTC to TAI, we need an other time : **TT** (Terrestrial Time), which is "the time used for geocentric apparent ephemeris".

We have :
TT = TAI + 32.184 s ;
TDB = TT + P, where P is a quantity inferior to 1.6 milliseconds.
In JEphem, we neglect P, so we have : | | (relation 2) |

For high precision, it's possible to find conversion programs. If you are interested, go to
ftp://heasarc.gsfc.nasa.gov/xte/calib_data/clock/bary. There you find a compressed archive, `bary.tar`

, which contains a file, `ctatv.c`

; it implements conversion from TT to TDB. They say the original routine is furnished by the BDL, but I couldn't find it in BDL's FTP.
From relations 1 and 2, we get : | | (relation 3) |

In JEphem, time computations are handled by two classes :
`tig.Time`

, which contain generic date formatting methods, which may be used in other programs.

I didn't use Sun's standard way to format dates (too lazy to read the doc...), and wrote date formatting methods for French and English. I hard coded both versions because I didn't want the methods to rely on property files.
`jephem.astro.spacetime.Time`

, which contains methods which are not likely to be used in other programs.
I put time constants in a separated interface : `jephem.astro.spacetime.TimeConstants`

### Time transfromations

In JEphem, I considered that **TDB = TT**. So the only thing is to compute **n** ( = TAI - UTC), often called **Delta T** in litterature.

The reference page for this is : http://hpiers.obspm.fr/eop-pc/earthor/utc/UTC-offsets_tab.html. A table with more convenient format can be found at :

ftp://heasarc.gsfc.nasa.gov/xte/calib_data/clock/bary. This permits to compute **n** from 1961 to today.

But [Ber98] says that formulae exist for other dates. Detailed explanations can be found at http://www.phys.uu.nl/~vgent/astro/deltatime.htm. In this page, several different formulae are presented. I finally implemented the formula presented in [Ber98], which has been used in some BDL theories :
For 1670 july 01 00:00:00 < t < 1961 jan 01 00:00:00, `deltaT = 15 + 32.5 u`^{2}

, where u is "the number of centuries elapsed since 1810".
I am not sure of the date to take to compute `u`

. I took 1810 jan 01 12:00:00.

for t < 1670 july 01 00:00:00, `deltaT = 0`

I have not (yet) implemented deltaT for future dates.