{"id":27862,"library":"hifitime","title":"Hifitime","description":"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.","status":"active","version":"4.3.0","language":"python","source_language":"en","source_url":"https://github.com/nyx-space/hifitime","tags":["time","astronomy","high-precision","datetime","rust"],"install":[{"cmd":"pip install hifitime","lang":"bash","label":"Standard install"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Epoch","correct":"from hifitime import Epoch"},{"note":"","wrong":"","symbol":"Duration","correct":"from hifitime import Duration"},{"note":"","wrong":"","symbol":"TimeScale","correct":"from hifitime import TimeScale"}],"quickstart":{"code":"from hifitime import Epoch, Duration, TimeScale\n\n# Create an epoch from a UTC string\ne = Epoch.from_gregorian_str(\"2023-10-01T00:00:00\", TimeScale.UTC)\nprint(e)  # Epoch { ... }\n\n# Add duration\nd = Duration.from_hours(1.5)\nepoch2 = e + d\nprint(epoch2)\n\n# Convert to different time scale\nprint(epoch2.to_utc_str())","lang":"python","description":"Basic usage: create an epoch, perform time arithmetic, and convert to string."},"warnings":[{"fix":"Use `Epoch.from_gregorian_str(s, TimeScale.UTC)` or pass the time scale parameter.","message":"By default, `Epoch` uses TAI (International Atomic Time) internally. All arithmetic and comparisons are in TAI. To work in UTC, explicitly specify the time scale.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to use new API: e.g., `epoch.to_tai_seconds()`. Refer to the migration guide.","message":"Prior 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.","severity":"breaking","affected_versions":"<3.0"},{"fix":"Keep hifitime updated to the latest version to ensure correct leap second handling.","message":"Leap 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `TimeScale.GPST` instead of `TimeScale.GPS`.","message":"The `TimeScale.GPS` is deprecated in favor of `TimeScale.GPST` (GPS Time).","severity":"deprecated","affected_versions":">=3.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from hifitime import Epoch` instead.","cause":"Importing incorrectly, e.g., `import hifitime` and then trying `hifitime.Epoch`.","error":"AttributeError: module 'hifitime' has no attribute 'Epoch'"},{"fix":"Use `TimeScale.GPST` instead of `TimeScale.GPS`.","cause":"Using deprecated or removed time scale name.","error":"ValueError: unknown time scale: GPS"},{"fix":"Use `epoch.to_gregorian_str()` or convert via seconds: `datetime.utcfromtimestamp(epoch.to_unix_seconds())`.","cause":"Trying to convert to Python datetime; that method may not exist in v4.","error":"AttributeError: 'Epoch' object has no attribute 'to_datetime'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}