Skip to content

API Map

STKCraft edited this page Nov 12, 2026 · 5 revisions

API map

The authoritative, exhaustive listing is the rustdoc at https://docs.rs/stkcraft-time. This page maps tasks to entry points.

Modules

Module Purpose
calendar Gregorian, Julian and Mixed calendars; JDN/JD/MJD conversion
convert UTC, TAI, TT, ET, GPS, UT1 conversions
coord TCG and TCB coordinate scales
dtdb IAU Fairhead & Bretagnon TDB model, including observer terms
tdb compact two-term TDB approximation
duration exact signed duration with checked arithmetic
eop IERS EOP table, series selection, interpolation
epoch Epoch and UtcDateTime
error TimeError
format ISO 8601, RFC 3339, RFC 2822, SPICE, strftime, etcal
leap LeapSecondTable, policies, sources, DELTET constants
lsk KPL/LSK parser
sclk KPL/SCLK type-1 parser and conversions
series TimeSeries iteration
contract type-level separation of NAIF ET and scientific TDB
mcp stdio MCP server (--features mcp)

Task to function

Task Call
Parse an LSK LeapSecondTable::from_lsk(text) / LeapSecondTable::builtin()
UTC → TAI convert::utc_to_tai(&dt, Calendar, &lsk)
TAI → UTC convert::tai_to_utc(epoch, Calendar, &lsk)
UTC → ET convert::utc_to_et(&dt, Calendar, &lsk)
ET → UTC convert::et_to_utc(et, Calendar, &lsk)
TAI → TT convert::tai_to_tt(epoch, &lsk)
TAI → GPS convert::tai_to_gps(epoch)
GPS → TAI convert::gps_to_tai(seconds)
UTC → UT1 convert::utc_to_ut1(&dt, Calendar, &lsk, &eop)
UT1 → UTC convert::ut1_to_utc(ut1, Calendar, &lsk, &eop)
UT1 - UTC convert::ut1_minus_utc(epoch, &lsk, &eop)
TAI → TCG / TCB coord::tai_to_tcg, coord::tai_to_tcb
TCG / TCB → TAI coord::tcg_to_tai, coord::tcb_to_tai
IAU TDB dtdb::tai_to_tdb_iau, dtdb::tdb_iau_to_tai
Observer TDB dtdb::dtdb_minus_tt_at_observer
Compact TDB tdb::tai_to_tdb, tdb::tdb_to_tai
Parse an SCLK kernel SclkKernel::parse(text, spacecraft_id)
Ticks → ET SclkKernel::ticks_to_et(ticks, &lsk)
ET → ticks SclkKernel::et_to_ticks(et, &lsk)
Fields ↔ ticks ticks_from_fields, fields_from_ticks
Parse encoded ticks parse_string, format_string
Parse EOP EopTable::from_finals2000a(text) and _series
Restrict to observations EopTable::observed_only()
Coverage / range LeapSecondTable::coverage(), EopTable::range()
Format format::iso8601, rfc3339, rfc2822, spice_calendar, strftime, etcal
Format with leap/calendar rules format::*_with + FormatOptions
Iterate epochs TimeSeries::inclusive, TimeSeries::exclusive
Checked epoch input Epoch::checked_from_parts, checked_from_tai_seconds
Checked duration Duration::checked_from_parts, checked_add, checked_sub, ...
Scientific vs NAIF contract contract::ScientificContext, contract::NaifEt

Types worth knowing

Type Note
Epoch canonical continuous TAI instant
UtcDateTime civil fields plus the calendar they belong to
Duration exact signed duration
LeapSecondTable parsed LSK plus policy and source
EopTable parsed UT1 - UTC samples
SclkKernel parsed type-1 clock
TimeError single error type for the library
ContractError errors from the contract module

Calendar helpers

pub const J2000_JDN: i64 = 2_451_545;
pub const GPS_EPOCH_JDN: i64 = 2_444_245;
pub const GREGORIAN_SWITCH_JDN: i64 = 2_299_161; // 1582-10-15

calendar::days_in_month(year, month, cal)
calendar::calendar_to_jdn(year, month, day, cal)
calendar::jdn_to_calendar(jdn, cal)
calendar::calendar_to_jd(year, month, day, hour, minute, second, cal)
calendar::jd_to_mjd(jd)

Error variants

TimeError covers the library:

Variant Meaning
InvalidDate { .. } date invalid for the calendar
InvalidTime { .. } hour or minute out of range
InvalidSecond seconds outside 0.0..61.0
InvalidLeapSecond a 23:59:60.x/23:59:59.x label the day does not have
UtcOutOfRange UTC outside kernel coverage
Ut1OutOfRange epoch or EOP sample outside the table
EopMissing / EopParse empty or invalid EOP data
SclkParse / SclkMissing / SclkUnsupported SCLK text, missing variable, unsupported clock type
SclkPartitionsUnsupported field/string conversion on a partitioned clock
LskParse / LskMissing LSK text or missing DELTET variable
InvalidFormat unsupported strftime token
Overflow reserved for checked arithmetic

Clone this wiki locally