Skip to content

API Map

stone edited this page Nov 13, 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
bdt checked BeiDou time coordinates
wgc_gps exercised WebGeocalc GPS and calendar conversions
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
kernel_date N0067 @date literals (exercised TPARTV/TPARSE profile)
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) / builtin() / lsk::parse_lsk(text)
Resolve a kernel @date kernel_date::parse_kernel_date(text)
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 legacy clock fields parse_string, format_string
Partition-aware clock strings encode_native_sclk, decode_native_sclk
WGC GPS week/TOW and calendar wgc_gps functions with an explicit LSK
SCLK string ↔ ET SclkClock { kernel, lsk } via the SclkMap trait
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
Checked UTC → ET / ET → UTC TimeContext::utc_to_et, TimeContext::et_to_utc
Scientific TDB (checked) ScientificContext::to_tdb, to_tdb_at_observer

Types worth knowing

Type Note
Epoch canonical continuous TAI instant
UtcDateTime civil fields; the calendar is passed to each conversion
Duration exact signed duration
LeapSecondTable parsed LSK plus policy and source
EopTable parsed UT1 - UTC samples
SclkKernel parsed type-1 clock
KernelDate seconds past J2000 plus normalized calendar fields
SclkClock / SclkMap kernel + LSK bound to string ↔ ET conversion
NaifEt / IauTdb model-tagged ET and scientific TDB, not interchangeable
TimeError single error type for the library
DtdbError invalid dtdb arguments or date outside the model guard
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 legacy field/string conversion on a partitioned clock; use native string APIs
LskParse / LskMissing LSK text or missing DELTET variable
InvalidFormat unsupported strftime token
KernelDateUnsupported unsupported @date literal; never a missing-kernel report
Overflow reserved for checked arithmetic

Clone this wiki locally