Skip to content


Hifitime is a time management library available in Rust and Python designed for scientific use or in programs that require high accuracy in time computations. It provides several main constructs:

  • Duration: a positive or negative duration with nanosecond precision
  • Epoch: a datetime with the time scale used to initialize it 1
  • TimeScale: an enum storing the different time scales (or "time systems") supported by hifitime
  • TimeSeries: an iterable structure that yields epochs at a fixed interval between a starting and ending datetime

This library guarantees exactly one nanosecond of precision in all epochs and duration computations for 65,536 years, centered on 01-JAN-1900 TAI. Refer to the design for details.

In addition to extensive unit and integration testing, hifitime is formally verified for operations on epochs and durations using the Kani model checking.

Time scales

Time scales (or "time systems" in the ESA lingo) are best explained by IAU SOFA:


Calculations in any scientific discipline may involve precise time, but what sets astronomy apart is the number and variety of time scales that have to be used.

There are several reasons for this: astronomers must continue to deal with the very phenomena that lie behind obsolete time scales, in particular the rotation of the Earth and the motions of the planets; as new time scales have been introduced, continuity with the past has been preserved, leaving in the various astronomical time scales a fossil record of former offsets and rates; and in astronomical applications the physical context of the “clock” matters, whether it is on Earth, moving or stationary, or on a spacecraft.

-- "SOFA Time Scales and Calendar Tools", Document version 1.61, section 3.1

Hifitime supports the following time scales:

  • Temps Atomique International (TAI)
  • Universal Coordinated Time (UTC)
  • Terrestrial Time (TT)
  • Ephemeris Time (ET) without the small perturbations as per NASA/NAIF SPICE leap seconds kernel
  • Dynamic Barycentric Time (TDB), a higher fidelity ephemeris time
  • Global Positioning System (GPST)
  • Galileo time scale (GST)
  • BeiDou time scale (BDT)
  • UNIX (although not exactly a time scale but very useful in interoperability with computers)
flowchart LR
    TAI:::engr -- +32.184 s --> TT
    GPST -- "-2,524,953,619 s" --> TAI
    TT -- "f(K, M0, M1, EB)" --> ET
    TT -- "g(357.528, 1.658e-3, 1.9...e-7)" --> TDB
    TAI -- IERS Leap seconds --> UTC

    classDef lead fill:green,opacity:0.6,stroke:darkgreen,stroke-width:2px,color:black
    classDef engr fill:dodgerblue,opacity:0.6,stroke:navy,stroke-width:2px,color:black

The following figures show the deviation of different time with respect to TAI scales from 01 January 1970 until 01 January 2023.