Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.4] - 2026-06-01

### Changed

- Refreshed the vendored `qtty-cpp` integration to the latest patch release,
including the corrected angular trig helpers and the `Ratio` FFI unit.
- Kept the `tempoch` workspace aligned with the new patch-level `qtty` API
and dependency versions used by the vendored adapter crates.

## [0.6.3] - 2026-05-30

### Removed
Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,21 @@ the horizon. Use the exported `DELTA_T_PREDICTION_HORIZON_MJD` typed

```toml
[dependencies]
tempoch = "0.6.2"
tempoch = "0.6.4"
```

Enable `serde` if you want to serialize typed times and periods:

```toml
[dependencies]
tempoch = { version = "0.6.2", features = ["serde"] }
tempoch = { version = "0.6.4", features = ["serde"] }
```

The `serde` feature composes with the ordinary runtime refresh behavior:

```toml
[dependencies]
tempoch = { version = "0.6.2", features = ["serde", "runtime-data-fetch"] }
tempoch = { version = "0.6.4", features = ["serde", "runtime-data-fetch"] }
```

## Serde
Expand Down
4 changes: 2 additions & 2 deletions tempoch-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tempoch-core"
version = "0.6.3"
version = "0.6.4"
edition = "2021"
authors = ["VPRamon <vallespuigramon@gmail.com>"]
description = "Core astronomical time primitives for tempoch."
Expand All @@ -19,7 +19,7 @@ path = "src/lib.rs"
[dependencies]
affn = { version = "0.7" }
chrono = "0.4.43"
qtty = { version = "0.8.4", features = ["julian-time", "astro"] }
qtty = { version = "0.8.5", features = ["julian-time", "astro"] }
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
siderust-archive = { version = "0.1", features = ["time"] }

Expand Down
8 changes: 4 additions & 4 deletions tempoch-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tempoch-ffi"
version = "0.6.3"
version = "0.6.4"
edition = "2021"
authors = ["VPRamon <vallespuigramon@gmail.com>"]
description = "C FFI bindings for tempoch — astronomical time primitives."
Expand All @@ -13,9 +13,9 @@ name = "tempoch_ffi"
crate-type = ["cdylib", "staticlib", "rlib"]

[dependencies]
tempoch = { path = "../tempoch", version = "0.6.3" }
tempoch-core = { path = "../tempoch-core", version = "0.6.3" }
qtty = "0.8.4"
tempoch = { path = "../tempoch", version = "0.6.4" }
tempoch-core = { path = "../tempoch-core", version = "0.6.4" }
qtty = "0.8.5"
qtty-ffi = "0.8"
chrono = "0.4.44"

Expand Down
103 changes: 96 additions & 7 deletions tempoch-ffi/include/tempoch_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ enum tempoch_scale_tag_t
TEMPOCH_SCALE_TAG_T_TCG = 5,
// Barycentric Coordinate Time.
TEMPOCH_SCALE_TAG_T_TCB = 6,
// Ephemeris Time (NAIF/SPICE compatibility marker; routes through TDB).
TEMPOCH_SCALE_TAG_T_ET = 7,
// GPS System Time (`TAI − 19 s`).
TEMPOCH_SCALE_TAG_T_GPST = 8,
// Galileo System Time (`TAI − 19 s`).
TEMPOCH_SCALE_TAG_T_GST = 9,
// BeiDou Navigation Satellite System Time (`TAI − 33 s`).
TEMPOCH_SCALE_TAG_T_BDT = 10,
// Quasi-Zenith Satellite System Time (aligned with GPST).
TEMPOCH_SCALE_TAG_T_QZSST = 11,
};
#ifndef __cplusplus
#if __STDC_VERSION__ >= 202311L
Expand Down Expand Up @@ -157,6 +167,28 @@ typedef struct tempoch_eop_values_t {
uint8_t ut1_observed;
} tempoch_eop_values_t;

// Split J2000-second instant on a scale-specific axis.
typedef struct tempoch_time_t {
// High part of the compensated J2000-second pair.
double hi_seconds;
// Low residual part of the compensated J2000-second pair.
double lo_seconds;
} tempoch_time_t;

// Decomposed GNSS week-number form since the constellation's defined epoch.
//
// Mirrors [`tempoch::GnssWeek`]. The week number is *full* (no rollover);
// `seconds_of_week` lies in `[0, 604_800)` and `subsecond_nanos` in
// `[0, 1_000_000_000)`.
typedef struct TempochGnssWeek {
// Full week number since the constellation's epoch (no rollover applied).
uint32_t week;
// Seconds since the start of `week`, in `[0, 604_800)`.
uint32_t seconds_of_week;
// Subsecond nanoseconds remainder, in `[0, 1_000_000_000)`.
uint32_t subsecond_nanos;
} TempochGnssWeek;

// A time period expressed in Modified Julian Date, suitable for C interop.
typedef struct tempoch_period_mjd_t {
// Start of the period (MJD).
Expand All @@ -165,13 +197,23 @@ typedef struct tempoch_period_mjd_t {
double end_mjd;
} tempoch_period_mjd_t;

// Split J2000-second instant on a scale-specific axis.
typedef struct tempoch_time_t {
// High part of the compensated J2000-second pair.
double hi_seconds;
// Low residual part of the compensated J2000-second pair.
double lo_seconds;
} tempoch_time_t;
// Validity horizons of the active time-data bundle, in MJD (UTC days).
//
// EOP horizon fields are `NaN` when no EOP data is loaded.
typedef struct TempochDataHorizons {
// First MJD covered by the EOP series, or `NaN` when no EOP is loaded.
double eop_start_mjd;
// Last observed (non-predicted) EOP MJD, or `NaN` when no EOP is loaded.
double eop_observed_end_mjd;
// Last EOP MJD including predictions, or `NaN` when no EOP is loaded.
double eop_end_mjd;
// Last MJD with observed ΔT in the archive-provided modern table.
double modern_delta_t_observed_end_mjd;
// Last MJD covered by the ΔT prediction table.
double delta_t_prediction_horizon_mjd;
// Source of the active bundle as a [`TempochTimeDataSource`] discriminant.
int32_t source;
} TempochDataHorizons;

// UTC date-time breakdown for C interop.
typedef struct tempoch_utc_t {
Expand Down Expand Up @@ -240,6 +282,29 @@ extern "C" {
// Last MJD with modern observed ΔT data (post-1955 atomic-clock era).
double tempoch_const_modern_delta_t_observed_end_mjd(void);

// Constant TT − TAI offset, in seconds (32.184).
double tempoch_const_tt_minus_tai_seconds(void);

// Number of nanoseconds in one SI second (1e9).
double tempoch_const_nanos_per_second(void);

// IAU time-scale epoch T0 as a Julian Day on the TT axis (1977-01-01 TAI).
double tempoch_const_iau_time_epoch_t0_jd(void);

// First JD(TT) of the high-accuracy TDB−TT model validity window.
double tempoch_const_tdb_tt_model_high_accuracy_start_jd(void);

// Last JD(TT) of the high-accuracy TDB−TT model validity window.
double tempoch_const_tdb_tt_model_high_accuracy_end_jd(void);

// ΔT = TT − UT1 in seconds for a UT1 Julian Day, using the compiled USNO
// model. Returns NaN when the requested epoch is outside the model domain.
double tempoch_delta_t_seconds(double jd_ut1);

// ΔT = TT − UT1 in seconds for a UT1 Julian Day, extrapolating with the
// long-term parabola beyond the tabulated range (always finite).
double tempoch_delta_t_seconds_extrapolated(double jd_ut1);

// Create a default context backed by the monthly ΔT model.
//
// # Safety
Expand Down Expand Up @@ -280,6 +345,24 @@ tempoch_status_t tempoch_context_allow_pre_definition_utc(const struct tempoch_c
// `out` must be a valid, writable pointer to `TempochEopValues`.
tempoch_status_t tempoch_eop_at(double mjd_utc, struct tempoch_eop_values_t *out);

// Decompose a GNSS-scale split instant into its week-number form.
//
// # Safety
// `out` must be a valid, writable pointer to `TempochGnssWeek`.

tempoch_status_t tempoch_time_to_gnss_week(struct tempoch_time_t value,
int32_t scale,
struct TempochGnssWeek *out);

// Build a GNSS-scale split instant from a week-number decomposition.
//
// # Safety
// `out` must be a valid, writable pointer to `TempochTime`.

tempoch_status_t tempoch_time_from_gnss_week(struct TempochGnssWeek value,
int32_t scale,
struct tempoch_time_t *out);

// Create a new MJD period. Returns `InvalidPeriod` when an endpoint is NaN or `start_mjd > end_mjd`.
//
// # Safety
Expand Down Expand Up @@ -429,6 +512,12 @@ tempoch_status_t tempoch_period_list_normalize(const struct tempoch_period_mjd_t
struct tempoch_period_mjd_t **out,
uintptr_t *out_count);

// Capture the active time-data status into `out`.
//
// # Safety
// `out` must be a valid, writable pointer to `TempochDataHorizons`.
tempoch_status_t tempoch_time_data_status(struct TempochDataHorizons *out);

// Validate and normalize a split J2000-second pair.
//
// # Safety
Expand Down
53 changes: 51 additions & 2 deletions tempoch-ffi/src/constats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
//! canonical typed helpers.

use tempoch::{
DELTA_T_PREDICTION_HORIZON_MJD, GPS_EPOCH_JD_UTC_DAY, GPS_EPOCH_TAI_MINUS_UTC, J2000_JD_TT_DAY,
MODERN_DELTA_T_OBSERVED_END_MJD, UNIX_EPOCH_JD_DAY, UTC_DEFINED_FROM_MJD_DAY,
delta_t_seconds, delta_t_seconds_extrapolated, DELTA_T_PREDICTION_HORIZON_MJD,
GPS_EPOCH_JD_UTC_DAY, GPS_EPOCH_TAI_MINUS_UTC, IAU_TIME_EPOCH_T0_JD_DAY, J2000_JD_TT_DAY,
MODERN_DELTA_T_OBSERVED_END_MJD, NANOS_PER_SECOND, TDB_TT_MODEL_HIGH_ACCURACY_END_JD_DAY,
TDB_TT_MODEL_HIGH_ACCURACY_START_JD_DAY, TT_MINUS_TAI, UNIX_EPOCH_JD_DAY,
UTC_DEFINED_FROM_MJD_DAY,
};

/// J2000.0 epoch as JD(TT) — 2 451 545.0.
Expand Down Expand Up @@ -98,6 +101,52 @@ pub extern "C" fn tempoch_const_modern_delta_t_observed_end_mjd() -> f64 {
MODERN_DELTA_T_OBSERVED_END_MJD.value()
}

/// Constant TT − TAI offset, in seconds (32.184).
#[no_mangle]
pub extern "C" fn tempoch_const_tt_minus_tai_seconds() -> f64 {
TT_MINUS_TAI.value()
}

/// Number of nanoseconds in one SI second (1e9).
#[no_mangle]
pub extern "C" fn tempoch_const_nanos_per_second() -> f64 {
NANOS_PER_SECOND as f64
}

/// IAU time-scale epoch T0 as a Julian Day on the TT axis (1977-01-01 TAI).
#[no_mangle]
pub extern "C" fn tempoch_const_iau_time_epoch_t0_jd() -> f64 {
IAU_TIME_EPOCH_T0_JD_DAY.value()
}

/// First JD(TT) of the high-accuracy TDB−TT model validity window.
#[no_mangle]
pub extern "C" fn tempoch_const_tdb_tt_model_high_accuracy_start_jd() -> f64 {
TDB_TT_MODEL_HIGH_ACCURACY_START_JD_DAY.value()
}

/// Last JD(TT) of the high-accuracy TDB−TT model validity window.
#[no_mangle]
pub extern "C" fn tempoch_const_tdb_tt_model_high_accuracy_end_jd() -> f64 {
TDB_TT_MODEL_HIGH_ACCURACY_END_JD_DAY.value()
}

/// ΔT = TT − UT1 in seconds for a UT1 Julian Day, using the compiled USNO
/// model. Returns NaN when the requested epoch is outside the model domain.
#[no_mangle]
pub extern "C" fn tempoch_delta_t_seconds(jd_ut1: f64) -> f64 {
delta_t_seconds(qtty::Day::new(jd_ut1))
.map(|s| s.value())
.unwrap_or(f64::NAN)
}

/// ΔT = TT − UT1 in seconds for a UT1 Julian Day, extrapolating with the
/// long-term parabola beyond the tabulated range (always finite).
#[no_mangle]
pub extern "C" fn tempoch_delta_t_seconds_extrapolated(jd_ut1: f64) -> f64 {
delta_t_seconds_extrapolated(qtty::Day::new(jd_ut1)).value()
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading
Loading