Registry / data / hifitime

hifitime

JSON →
library4.3.0pypypi✓ verified 83d ago

Hifitime is a high-precision time and date library for Python, built on top of the Rust `hifitime` crate. It provides nanosecond-level precision, support for time scales (TAI, UTC, TT, etc.), durations, and astronomical time functions. Current version is 4.3.0, requiring Python >=3.9. Releases are frequent, with semver updates.

pip install hifitime
INSTALL
IMPORT
SIG · HIFITIME
H
hifitime
datapythonv4.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Epoch
from hifitime import Epoch
Duration
from hifitime import Duration
TimeScale
from hifitime import TimeScale

Basic usage: create an epoch, perform time arithmetic, and convert to string.

from hifitime import Epoch, Duration, TimeScale # Create an epoch from a UTC string e = Epoch.from_gregorian_str("2023-10-01T00:00:00", TimeScale.UTC) print(e) # Epoch { ... } # Add duration d = Duration.from_hours(1.5) epoch2 = e + d print(epoch2) # Convert to different time scale print(epoch2.to_utc_str())
Debug
Known issues
gotchaBy default, `Epoch` uses TAI (International Atomic Time) internally. All arithmetic and comparisons are in TAI. To work in UTC, explicitly specify the time scale.
fix
Use `Epoch.from_gregorian_str(s, TimeScale.UTC)` or pass the time scale parameter.
affects: all
breakingPrior to version 3.0, the library used a different API (e.g., `epoch.tai_seconds()`). In v3+, methods are renamed and the internal representation changed.
fix
Update to use new API: e.g., `epoch.to_tai_seconds()`. Refer to the migration guide.
affects: <3.0
gotchaLeap seconds are handled automatically in conversions between TAI and UTC. However, the library does not expose historical leap second tables directly; it relies on the bundled data. Always update the library to get the latest leap second information.
fix
Keep hifitime updated to the latest version to ensure correct leap second handling.
affects: all
deprecatedThe `TimeScale.GPS` is deprecated in favor of `TimeScale.GPST` (GPS Time).
fix
Use `TimeScale.GPST` instead of `TimeScale.GPS`.
affects: >=3.0
Errors
Common errors & fixes
AttributeError: module 'hifitime' has no attribute 'Epoch'
Importing incorrectly, e.g., `import hifitime` and then trying `hifitime.Epoch`.
fix
Use `from hifitime import Epoch` instead.
ValueError: unknown time scale: GPS
Using deprecated or removed time scale name.
fix
Use `TimeScale.GPST` instead of `TimeScale.GPS`.
AttributeError: 'Epoch' object has no attribute 'to_datetime'
Trying to convert to Python datetime; that method may not exist in v4.
fix
Use `epoch.to_gregorian_str()` or convert via seconds: `datetime.utcfromtimestamp(epoch.to_unix_seconds())`.
Upgrade
Version history
4.3.0latest on PyPI · released May 1, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
hifitime — pip install hifitime · libregistry