STKCraft-time
STKCraft project: https://www.stkcraft.com Repository: https://github.com/spacelibres/STKCraft-time
A NAIF/SPICE-aligned time library written in Rust.
stkcraft-time implements the time-scale model documented by the NASA
Navigation and Ancillary Information Facility (NAIF) in the SPICE Time
Subsystem Required Reading and driven by a Leapseconds Kernel (LSK).
It does not link CSPICE. Text-kernel decimal arithmetic follows NAIF's
NPARSD operation order; see ATTRIBUTION.md for provenance.
- API guide:
docs/API.md - API reference: https://docs.rs/stkcraft-time
- Wiki: https://github.com/spacelibres/STKCraft-time/wiki
- MCP server:
docs/MCP.md - Runnable tour:
examples/api_tour.rs - Agent skills:
.agents/skills/ - crates.io: https://crates.io/crates/stkcraft-time
- Reference:
cargo doc --open
Install: cargo add stkcraft-time, or add
stkcraft-time = "0.1.25" to [dependencies]. With no_std, use default-features = false.
Project status
- Latest release: v0.1.25 on GitHub Releases, including release-mode binaries for Linux, macOS (x86_64 and arm64) and Windows.
- Published on crates.io as
stkcraft-time0.1.25, with API docs on docs.rs. - Minimum supported Rust version: 1.75.
- The library is
no_stdcompatible withalloc; the optional MCP server requiresstd.
Installation
[]
= "0.1.25"
no_std plus alloc:
= { = "0.1.25", = false }
The MCP server and the validation binaries are optional:
To track the repository instead of a crates.io release, pin a tag:
= { = "https://github.com/spacelibres/STKCraft-time", = "v0.1.25" }
Releases
Every vX.Y.Z tag publishes a GitHub Release with optimized binaries
built by cargo build --release --features mcp --bins:
| Platform | Archive |
|---|---|
| Linux x86_64 | stkcraft-time-vX.Y.Z-linux-x86_64.tar.gz |
| macOS x86_64 | stkcraft-time-vX.Y.Z-macos-x86_64.tar.gz |
| macOS arm64 | stkcraft-time-vX.Y.Z-macos-aarch64.tar.gz |
| Windows x86_64 | stkcraft-time-vX.Y.Z-windows-x86_64.zip |
Each archive contains stkcraft-mcp, sclk-check, ut1-check,
tdb-compare, wgc-compare, README.md, LICENSE and
CHANGELOG.md. SHA256SUMS.txt is attached separately. Release notes
are in
docs/releases/.
Design rules
-
The LSK is the only source of truth.
DELTET/DELTA_T_A,DELTET/K,DELTET/EB,DELTET/MandDELTET/DELTA_ATare read from the kernel. No leap-second value is hard-coded in the conversion logic. -
TAI is the internal canonical scale.
Epochstores an integer count of TAI seconds plus nanoseconds since2000-01-01T00:00:00 TAI. UTC is a civil representation, not an internal time scale. This keeps the representation monotonic across leap seconds. -
UTC conversion uses the day-length table, not the
DeltaETformula. For every UTC day affected by a leap second, the day is 86400, 86401 or 86399 seconds long.23:59:60.xis legal only on a 86401-second day; conversely23:59:59.xdoes not exist on a 86399-second day. TheTDB - UTC = 32.184 + DeltaAT + K*sin(E)expression is not used to convert across a leap-second instant. -
Scales are distinct types. UTC, TAI, TT, TDB/ET and GPS are never interchangeable. Conversion is only possible through explicit constructors.
-
No future leap-second policy is inferred by default. Leap seconds are data. The default
TableDrivenpolicy follows the supplied LSK and freezesTAI - UTCafter its last entry. A caller that wants to model an explicit assumption can selectLeapSecondPolicy::FrozenAfter; the crate never infers a policy from a date on its own.
Kernel selection
Time conversion results depend on the leap-second kernel you load. This
mirrors the Kernel selection control in the JPL WebGeocalc Time
Conversion tool: the same UTC instant maps to a different TAI - UTC
after a leap second if two kernels disagree about that leap second.
LeapSecondTable::from_lsk(text)loads an explicitKPL/LSKkernel. This is the recommended entry point in production. Every conversion is a pure function of that kernel.LeapSecondTable::builtin()is a snapshot ofnaif0012.tlsbundled for convenience. Its last leap-second entry is2017-01-01. It is not a privileged source of truth.LeapSecondTable::coverage()returns the(first, last)effective dates the kernel actually covers.- UTC dates before the first kernel entry are rejected
(
UtcOutOfRange); nothing is guessed. - UTC dates after the last entry hold the last
TAI - UTCvalue. This is NAIF's documented behaviour, not data invented here: a kernel cannot know about a leap second announced after it was released. Update the kernel to extend trustworthy coverage.
Two kernels that differ in DELTET/DELTA_AT therefore give different
results; tests/kernel_selection.rs asserts this explicitly.
Kernel types in WebGeocalc and in this crate
In WebGeocalc's Kernel selection, a "kernel" is a SPICE data file, not an operating-system kernel. Only some of the loaded files participate in time conversion:
| WebGeocalc item | Kernel | Purpose | stkcraft-time API |
|---|---|---|---|
| Latest leap-seconds kernel | LSK | UTC–TAI leap seconds, DELTET constants |
LeapSecondTable::builtin() / from_lsk() |
| Spacecraft clock | SCLK | Mission clock ticks/strings ↔ ET/TAI | SclkKernel::parse() |
| IERS EOP (not shown on that screen) | finals2000A.all |
UT1 - UTC |
EopTable::from_finals2000a*() |
| Solar-system kernels | SPK/PCK | Trajectories and planetary constants | Not used for time conversion |
| Ground-station kernel set | Station kernels | Station locations | Not used for time conversion |
SPK/MK |
MK (meta-kernel) | A list of files to load | Not loaded; it is only a manifest |
UTC/TT/TDB/GPS conversions share the LSK; only the spacecraft-clock encoding needs a mission-specific SCLK. UT1 is the exception: it needs an independent EOP table because it measures the actual rotation of the Earth. SPK/PCK/FK/IK contain geometry and trajectory data and are not needed by a pure time conversion.
use ;
use ;
let text = read_to_string.expect;
let lsk = from_lsk.expect;
let utc = new;
let tai = utc_to_tai.expect;
let et = tai_to_et;
For complete call examples, including SCLK and EOP/UT1, see
docs/API.md and the runnable
examples/api_tour.rs.
Kernel date literals
A text kernel can write an epoch as @2000-JAN-01-12:00:00. NAIF
resolves that literal with TPARSE into seconds past J2000, without any
UTC, TT or TDB conversion and without a leap-second kernel.
stkcraft_time::kernel_date::parse_kernel_date performs the same
resolution:
use parse_kernel_date;
let epoch = parse_kernel_date.expect;
assert_eq!;
assert_eq!;
A day past the end of its month rolls forward as NAIF does. Unsupported
forms return KernelDateUnsupported, never a missing-kernel error and
never a substitute epoch. Two-digit years and ordinal day-of-year forms
(@2000-060) are rejected.
Measured against the live WGC2 API
tools/wgc2_kernel_sweep.py selects individual LSK kernels through the
WGC2 kernels parameter ({"type": "KERNEL", "path": "pds/wgc/kernels/lsk/naif0012.tls"})
and converts the same UTC epochs to TDB. Measured on 2026-11-10 against
WGC2 2.11.2 (build 5520 N67):
| UTC | naif0012 ET | naif0011 ET | naif0010 ET |
|---|---|---|---|
2017-06-01T00:00:00 |
549547269.184903 | 549547268.184903 | 549547267.184903 |
2015-06-01T00:00:00 |
486388867.184915 | 486388867.184915 | 486388867.184915 |
2016-12-31T23:59:60.5 |
536500868.68393 | 536500868.68393 | 536500867.68393 |
2024-01-01T00:00:00 |
757339269.183906 | 757339268.183906 | 757339267.183906 |
After the 2015-07-01 leap second naif0011 is one second behind
naif0012, and naif0010 is two seconds behind — exactly the leap
seconds each kernel lacks. This crate reproduces every comparable value
to WGC2's rounding (≤ 5e-7 s).
For 2016-12-31T23:59:60.5 under naif0011/naif0010, WGC2 still
returned a number, but those kernels do not declare that leap second.
This crate rejects the input with InvalidLeapSecond, which is SPICE's
documented treatment of a leap-second label missing from the kernel. The
result is not guessed.
The CSV is committed as tests/golden/wgc2_kernel_selection.csv, so the
check runs offline. Regenerate it with:
Implemented scales
| Scale | Definition used here |
|---|---|
| UTC | Civil representation with leap seconds |
| TAI | Continuous atomic time |
| TT | TAI + 32.184 s |
| ET (NAIF) | TT + K*sin(E), E = M + EB*sin(M), M = M0 + M1*t |
| TDB (compact) | TT + 0.001658*sin(g) + 0.000014*sin(2g) |
| GPS | TAI - 19 s, zero at 1980-01-06T00:00:00 UTC |
| UT1 | Earth-rotation scale, UTC + (UT1 - UTC); requires IERS EOP |
| TCG | TT + L_G/(1-L_G)*(JD_TT - T0)*86400 (IAU coordinate scale) |
| TCB | TDB + (L_B*(JD_TDB - T0)*86400 - TDB0)/(1-L_B) (IAU coordinate scale) |
ET is TDB seconds past the J2000 epoch (2000-01-01T12:00:00 TDB),
matching the SPICE convention. Use ET for NAIF/SPICE interoperability,
tdb for the compact NASA HEASARC approximation,
and dtdb for the 787-term geocentric IAU/SOFA model. The compact model
is not a guaranteed improvement over NAIF: a daily 1950-2050 comparison
with ERFA has a maximum residual of about 36.5 us.
Accuracy statement
Timekeeping does not have an absolute accuracy independent of a reference. This crate targets the following verifiable properties:
- Internal storage is integer seconds plus nanoseconds. No floating-point accumulation is used for epoch arithmetic. The nanosecond field is a representation step, not a claim of nanosecond accuracy.
- UTC/TAI conversion matches the LSK for every leap-second boundary,
including
23:59:60.x. - TT/TDB conversion follows NAIF's published model, whose stated accuracy is about 30 microseconds (small-period terms are ignored).
- ET is an
f64by definition, exactly as in SPICE; thef64boundary therefore bounds ET precision.
The only accuracy figures quoted here are either published by NAIF (about 30 µs for the TDB model) or measured against a reference engine (CSPICE). No accuracy is asserted that the underlying data does not support.
Bit-for-bit equality with CSPICE is validated by 82 golden vectors
generated offline with tools/gen_golden.py. The current maximum
UTC-to-ET difference is 1.1e-12 s. CSPICE is not a build or runtime
dependency.
WGC2 API comparison
WGC2 exposes a REST API at
https://wgc2.jpl.nasa.gov:8443/webgeocalc/api/ and performs time
conversion through calculationType: "TIME_CONVERSION". A live request
for two representative epochs returned:
| UTC | WGC2 ET (s) | CSPICE / this crate ET (s) | Difference |
|---|---|---|---|
2016-12-31T23:59:60.5 |
536500868.68393 |
536500868.6839298 |
2.0e-7 s |
2000-01-01T12:00:00 |
64.183927 |
64.18392728473108 |
2.8e-7 s |
The differences are WGC2's output rounding. WGC2 is a CSPICE front-end;
the underlying model is identical. This crate agrees with CSPICE to
1.1e-12 s. It is therefore numerically aligned with NASA's engine,
not physically more accurate; its difference is an integer-nanosecond
internal representation and output formatting that prints more digits
than WebGeocalc's rounded values. More printed digits are not more
accuracy.
Reproduce the comparison with:
The script produces one report with three sections:
- TDB conversion — submits
TIME_CONVERSIONto WGC2, runscargo run --bin wgc-comparefor the same epochs, and compares both against WGC2 and againsttests/golden/utc_to_et.csv. - TDB model: NAIF ET vs IAU — shows the difference between the NAIF
model used for SPICE interoperability and the IAU Fairhead-Bretagnon
TDB. It is epoch-dependent:
+26.570 usat2000-01-01T12:00:00 UTC, and across a full year it ranges about-29to+29 us, consistent with NAIF's stated ~30 us bound. The printed decimals are arithmetic, not an accuracy claim. Reproduce the independent reference withpython tools/validate_et_vs_iau.py --year 2000(CSPICE + ERFA). - UT1 — probes WGC2 to show that it has no UT1 time system, then
validates UT1 against the real IERS data and leap physics through
tools/validate_ut1.py. See No external UT1 engine above.
A representative run reports max WGC2 vs crate difference: 2.847e-07 s,
max crate vs CSPICE golden difference: 9.095e-13 s,
largest ET-vs-IAU-TDB over these epochs: 26.570 us, and
OVERALL: PASS. Pass --skip-ut1 or --skip-tdb-model to omit a section,
or --eop <path> to point the UT1 section at a specific
finals2000A.all.
Scope
For new integration code, read Time contracts.
contract::TimeContext::new(&lsk) is the default NAIF/SPICE path and
returns typed NaifEt. ScientificContext is an explicit TT(TAI)/ERFA
scientific path returning a separate IauTdb, with geocentric or supplied
observer-dependent terms. Existing low-level APIs retain their behavior.
Implemented:
- Gregorian, Julian and Mixed calendars
- Julian Date and Modified Julian Date (
MJD = JD - 2400000.5, explicitly) - Exact
Durationarithmetic andTimeSeries TimeScaleidentifiersno_stdsupport (alloc+libm;stdis the default feature)- Pre-1972 UTC drift via the optional IAU SOFA
iauDatmodel - LSK parsing (
KPL/LSKtext kernel subset) - UTC <-> TAI <-> TT <-> TDB/ET <-> GPS
- UT1 via an IERS Earth Orientation Parameters table (
eopmodule) - TCG and TCB IAU coordinate scales (
coordmodule) - IAU TDB model, Fairhead & Bretagnon 787-term series and explicitly
supplied observer-dependent SOFA/ERFA terms (
dtdbmodule) - SCLK type-1 kernel parsing and tick/time conversion (
sclkmodule) - ISO 8601, RFC 3339, RFC 2822 and C89
strftime-style formatting etcal(no kernel required)
Not implemented in this version:
- Full SPICE
str2ettoken grammar (this version provides typed constructors only) - SCLK partition-aware field/string conversion and clock types other than type 1
- Automatic policy selection without an explicit date (the caller
supplies
LeapSecondPolicy)
Spacecraft clocks (SCLK)
SclkKernel::parse(text, id) reads a KPL/SCLK type-1 kernel and
converts between encoded ticks, the parallel time system, and ET/TAI.
The clock may use TDB or TT coefficients (SCLK01_TIME_SYSTEM); the LSK
is used only for the TT-to-ET step.
Scalar assignments such as SCLK01_N_FIELDS_74 = 2 and equivalent
parenthesized values are accepted. TDT clocks retain the original parallel
TT through the N0067 UNITIM arithmetic in both directions, without an
intermediate integer Epoch or origin shift.
Independent CSPICE references exercise both sct2e and sce2c, including
coefficient neighbors and the formerly failing 0.93 ns and 119.21 ns cases.
The validator defaults to bit-exact acceptance, uses lossless numeric output
and loads the same selected LSK on both sides. Finite-sample equality is
not a physical clock-calibration accuracy guarantee.
Scope: encoded-tick conversions and field/string encoding are exact within a partition starting at zero. Partition-aware field/string conversion is not implemented. Encoded tick/time conversions enforce the cumulative partition duration, rounding each readout to integral ticks as NAIF does; resets may start below the previous partition end. Ticks before the first coefficient or beyond the declared domain are rejected. A standalone map without partition metadata has no declared upper bound. Only clock type 1 is supported.
Formatting
use ;
use ;
let dt = new;
assert_eq!;
assert_eq!;
assert_eq!;
// Rounding that reaches a leap second needs the day length.
let lsk = builtin.unwrap;
let options = new.with_leap_seconds;
let last_second = new;
assert_eq!;
Supported C89 tokens: %Y %y %m %d %e %H %M %S %j %a %A %b %B %z %Z %f %%.
FormatOptions also selects the calendar used when a carry moves the
date, so Julian dates roll into 1500-02-29 rather than 1500-03-01.
Leap-second policy note
Leap seconds are announced by the International Earth Rotation and
Reference Systems Service (IERS), and NAIF publishes an updated LSK when
one is needed. The 27th CGPM (2022), Resolution 4, set a target of no
new leap seconds by 2035, with the maximum |UT1 - UTC| allowed to
grow.
Any other date, including 2027-05-20, must be treated as a policy
assumption supplied by the caller, with a citation to the BIPM, IERS or
NAIF document that establishes it. This crate does not encode such a
date.
Before 1972, UTC seconds were not SI seconds. The default
LeapSecondSource::IersOnly matches the NAIF LSK and rejects pre-1972
UTC. Selecting LeapSecondSource::Sofa additionally enables the IAU
SOFA iauDat drift model for 1960-1972, including positive and negative
mini-leaps in the final minute and fractional TAI - UTC. Historical
conversions are checked against independent ERFA vectors at every model
transition. The SOFA drift/mini-leap convention has overlaps/gaps of a few
nanoseconds at some day ends; inverse conversion gives actual midnight
to the new date and returns UtcOutOfRange for unrepresentable gaps.
Integer nanosecond storage does not make these historical labels an exact
bijection at those boundaries.
UT1 and IERS EOP
UT1 is the Earth-rotation time scale. It is not derivable from the Leapseconds Kernel: the LSK knows when civil UTC was stepped, but only an IERS Earth Orientation Parameters (EOP) product knows how the Earth actually rotated. The LSK and the EOP data are two independent data sets.
This crate reads the UT1 - UTC series of the IERS finals2000A.all
product into an EopTable and exposes UT1 through
convert::ut1_minus_utc, convert::tai_to_ut1, convert::ut1_to_tai,
convert::utc_to_ut1 and convert::ut1_to_utc. Both the Bulletin A and
Bulletin B series are supported (see below).
Data is deployment-time only
No EOP file is bundled. Fetch it once at deployment time:
# --insecure only if TLS verification is unavailable in the target environment
If the IERS endpoint is slow or unreachable from your network, point the script at a mirror or a local copy. The endpoint can be set per run or once per shell:
tools/validate_ut1.py accepts the same --url flag and
STKCRAFT_EOP_URL variable, and skips the download entirely when
--eop already points at an existing file.
Then load it from disk:
use EopTable;
let text = read_to_string?;
let eop = from_finals2000a?;
The crate performs no network I/O at runtime. finals2000A.all is
refreshed daily by IERS; re-run the script to update it.
Fixed-column format, not whitespace-delimited
finals2000A.all is fixed-column. When the month or day has two digits
the year, month and day run together (73 110 is 1973-01-10), so a
whitespace split shifts every later column and silently reads a different
quantity. This parser uses the documented columns:
| Field | Columns (1-based) |
|---|---|
| Year / Month / Day | 1-2 / 3-4 / 5-6 |
| MJD | 7-15 |
I/P flag (Bulletin A) |
58 |
UT1 - UTC Bulletin A (s) |
59-68 |
UT1 - UTC Bulletin B (s) |
156-165 |
Rows with a blank UT1 - UTC column (future placeholders) are skipped.
Predicted rows (P) are retained and flagged; use
EopTable::observed_only to restrict a table to IERS observations, which
makes the supported interval explicit.
Two UT1-UTC series: Bulletin A and Bulletin B
finals2000A.all carries two UT1 - UTC series. Bulletin A is the
rapid-service and predicted series (columns 59-68); Bulletin B is the
final solution (columns 156-165). They can differ by several milliseconds
for old data. Choose with EopSeries:
EopTable::from_finals2000a/from_finals2000a_series(text, EopSeries::BulletinA)— the default; matches the product name.EopSeries::BulletinB— the final solution where available.EopSeries::FinalPreferred— Bulletin B where present, otherwise Bulletin A. This matches the combinedUT1_UTCcolumn used by astropy's IERS tables.
Compatibility with astropy's IERS implementation was measured over 1,744
samples spanning the file: ordinary days agree to 1.1e-16 s and leap
days to 0 s. Reproduce with python tools/validate_ut1_astropy.py.
Leap seconds are removed before interpolating
UT1 - UTC jumps by one second when a positive leap second is inserted,
because UTC is delayed while UT1 keeps running. Naively interpolating the
daily samples across a leap-second day smears that one-second step over
the whole day, giving a half-second error at local noon.
convert::ut1_minus_utc removes the known step (from the LSK) before
interpolating, using the true UTC day length of 86400, 86401 or 86399
seconds. On real finals2000A.all data at 2016-12-31T12:00:00 this
gives -0.408239 s; the naive interpolation gives +0.091761 s, a
difference of 0.5 s. The raw EopTable::ut1_minus_utc remains
available for table inspection and for use away from leap boundaries.
No external UT1 engine; validation against the data
The JPL WebGeocalc / CSPICE have no UT1 time system. The WGC2 API rejects
both "timeSystem": "UT1" and "outputTimeSystem": "UT1" with
No enum constant ...TimeStandard.UT1, and UT1 appears nowhere in the
Time Conversion documentation. UT1 therefore cannot be compared against
WGC2, and no such comparison is claimed.
UT1 is validated instead against the real IERS file and against an independent implementation:
- Data fidelity (
tools/validate_ut1.py): on all 20,037 usable days, the value at00:00:00 UTCreproduces the table entry exactly (max|crate - table|=0 s). - Leap physics: on all 25 leap-boundary days, the leap-aware value
at
12:00stays within 1.7 ms of the day-start value (the LOD drift), while naive interpolation is at least 0.498 s wrong. - Independent implementation (
tools/validate_ut1_astropy.py): theFinalPreferredseries agrees with astropy's combined IERS column over 1,744 samples to1.1e-16 son ordinary days and0 son leap days.
Scope note
UT1 is an Earth-rotation time scale. This API provides leap-aware daily
EOP interpolation, not a complete instantaneous Earth-orientation model.
IERS Conventions, section 5.5.3.1
requires additional subdaily ocean-tide and libration terms for the
corresponding high-accuracy calculation; these are not implemented. EOP
measurement and prediction uncertainties are not propagated. Select
observed_only() when predictions are inappropriate. Matching a table
interpolator does not establish zero physical error.
TCG and TCB
TCG and TCB are the IAU 2000/2006 coordinate scales. They are linear in TT and TDB and need no kernel:
| Scale | Definition |
|---|---|
| TCG | TT + L_G/(1-L_G)*(JD_TT - T0)*86400 |
| TCB | TDB + (L_B*(JD_TDB - T0)*86400 - TDB0)/(1-L_B) |
with T0 = 1977-01-01T00:00:00 TAI (JD 2443144.5003725 in TT),
L_G = 6.969290134e-10, L_B = 1.550519768e-8 and TDB0 = -6.55e-5 s.
Neither the WebGeocalc API nor CSPICE exposes TCG/TCB: the WGC2 API
rejects both with No enum constant ...TimeStandard.TCG/TCB. They are
validated against ERFA/SOFA through astropy. Measured over 950 TAI
epochs from 1972 to 2050:
- TT agrees with ERFA exactly (0 s).
- TCG agrees to
2.384e-7 s, which is thef64spacing of a value near1.6e9seconds at 2050, not a model error. - TCB agrees to
2.384e-7 s, the samef64limit.
TCB uses the IAU TDB model from the dtdb module, not the NAIF ET
approximation. That model is the 787-term Fairhead & Bretagnon series:
it agrees with ERFA dtdb to 4.6e-18 s over 1218 samples from 1950 to
2050, and ERFA states the series is accurate to about 3 ns in that
interval. NAIF ET, accurate to about 30 us, remains available separately
for SPICE interoperability; the two are not interchangeable.
That 30 us to 3 ns improvement is the point of the port. It matters when the reference chain is IAU/SOFA (VLBI, pulsar timing, relativistic time transfer, comparing against ERFA-based pipelines) or when TDB feeds an ephemeris at the microsecond level. It does not matter for ordinary mission planning, where 30 us is far below every other error term.
Coordinate scales are f64 seconds past JD 2451545.0; at modern epochs
that spacing is about 60 ns.
Usage
use Calendar;
use ;
use ;
let lsk = builtin?;
let dt = new;
let tai = utc_to_tai?;
let back = tai_to_utc?;
assert_eq!;
# Ok::
MCP server
The optional mcp feature builds a stdio MCP server that exposes the
conversion API as JSON-RPC tools:
Example client configuration:
See docs/MCP.md for the tool list and schemas. Agent
skills are in .agents/skills/.
References
- NAIF, SPICE Time Subsystem Required Reading (
time.req) - NAIF, Leapseconds Kernel (
lsk.req) - NAIF,
naif0012.tls - IERS Bulletin C (leap-second announcements)
- IERS,
finals2000A.all(Earth Orientation Parameters) - BIPM, 27th CGPM (2022), Resolution 4
Build and verification
RUSTDOCFLAGS="-D warnings"
The library is no_std compatible with alloc:
= { = "0.1.25", = false }
In no_std builds, libm supplies sin, cos, floor and round;
calendar and epoch arithmetic remain integer-based. The std feature is
enabled by default and only adds std::error::Error.
Alignment with NAIF (release criterion)
The release criterion is numerical alignment with NASA NAIF/SPICE:
- 82 CSPICE golden vectors: max UTC-to-ET difference
1.1e-12 s. - Live WGC2
TIME_CONVERSION: max2.847e-7 s(its output rounding). - Kernel selection:
naif0012/naif0011/naif0010reproduced exactly (see Measured against the live WGC2 API). - SCLK: 10,871 independent forward/inverse CSPICE cases match bit for bit. Explicit Epoch/TAI conversions still quantize to integer nanoseconds.
Scales that NAIF does not define are not part of this criterion: UT1 is validated against IERS data, and TCG/TCB against ERFA. Neither CSPICE nor WebGeocalc exposes them.
Optional: formal verification (Kani)
Kani is not a release gate. It is an optional extra for the integer representation layer; the release criterion above is NAIF alignment.
src/verification.rs contains #[kani::proof] harnesses for Duration
and Epoch normalization. Status, stated precisely:
- Kani 0.68.0 publishes binaries only for Linux and macOS. There is no
Windows build, and this project's development host is
x86_64-pc-windows-msvc, so the harnesses have not been executed on this machine. - They can be run on
ubuntu-latestby manually dispatching.github/workflows/kani.yml. tests/properties.rsexercises the same invariants with 200,000 deterministic samples undercargo test. Those checks execute here, but they are runtime tests, not proofs.
To run the proofs locally on a supported platform:
License
MIT License. See LICENSE.
The bundled src/naif0012.tls is a NAIF data product and is included
with attribution. It is not covered by the crate's MIT license.
Contributing
See CONTRIBUTING.md for development setup, release
procedures and validation commands. Security reports go through
SECURITY.md; all participation is covered by
CODE_OF_CONDUCT.md. Support resources are listed
in SUPPORT.md.
Citation
See CITATION.cff.
Precision and representation
Epochis an integer count of TAI seconds plus nanoseconds since2000-01-01T00:00:00 TAI. The integer fields can address about ±2.9×10¹¹ years, and the nanosecond field is a 1 ns representation step. Addressability is not accuracy: a conversion is only defined where the loaded kernel, the calendar rules and (for UT1) the EOP table support the date.Durationis exact integer arithmetic; no floating-point accumulation is used for epoch or duration arithmetic.- TAI is the glitch-free internal reference. UTC is a civil representation, not an internal scale.
- NAIF
ET, the compact two-termTDBapproximation and the 787-term geocentric IAUTDBmodel are separate functions with different limits. - Against 82 CSPICE reference vectors, the maximum UTC-to-ET difference is currently 1.1×10⁻¹² s. This is agreement with a reference engine, not a physical accuracy claim.
Leap-second regime
The library distinguishes three concepts:
- the table (
LEAPentries from the LSK); - the source (
IersOnlyorSofafor pre-1972); - the policy that decides what happens after a chosen epoch.
The default policy is TableDriven: the last table entry remains in
force indefinitely, so if no further leap second is announced, TAI−UTC
freezes automatically. A caller that wants to model the CGPM decision to
stop leap seconds can use LeapSecondPolicy::frozen_after(year, month, day) (or the FrozenAfter { jdn } variant); from that date onward,
later table entries are ignored and the last value is kept. No future
date is hard-coded in the default path.