Skip to content

Add time scale conversion functions and TempochScale enum#4

Merged
VPRamon merged 3 commits intomainfrom
extend-ffi
Feb 28, 2026
Merged

Add time scale conversion functions and TempochScale enum#4
VPRamon merged 3 commits intomainfrom
extend-ffi

Conversation

@VPRamon
Copy link
Member

@VPRamon VPRamon commented Feb 28, 2026

This pull request adds comprehensive support for time scale conversions in the FFI layer, enabling conversions between Julian Date (TT) and a wide range of standard astronomical and civil time scales. It introduces both individual conversion functions and a generic dispatch mechanism, along with an enumeration for time scales to facilitate these operations from C/C++ code.

Key changes:

Time Scale Conversion Functions:

  • Added FFI functions for converting Julian Date (TT) to and from the following time scales: TDB, TT, TAI, TCG, TCB, GPS, UT, JDE, and Unix Time. Each function is exposed via extern "C" for use in C/C++ environments. [1] [2]

Generic Conversion Dispatch:

  • Introduced tempoch_jd_to_scale and tempoch_scale_to_jd functions, which allow conversion between Julian Date and any supported time scale using a new TempochScale enum as a parameter. This makes it easy to perform conversions when the target scale is not known at compile time. [1] [2]

Time Scale Enumeration:

  • Defined a new TempochScale enum in both C and Rust, listing all supported time scales with explicit integer values for safe interop. This is used by the generic conversion functions for dispatch. [1] [2]

ΔT Calculation:

  • Added tempoch_delta_t_seconds, an FFI function to compute ΔT (TT − UT1) in seconds for a given Julian Date, using the model from tempoch-core. [1] [2]

Internal Improvements:

  • Updated Rust imports to include all relevant time scale types, ensuring the new conversion functions are available and type-safe.

These changes significantly enhance the flexibility and completeness of the time scale conversion API, making it much easier to interoperate with various time standards in cross-language contexts.

@VPRamon VPRamon self-assigned this Feb 28, 2026
@github-actions
Copy link

github-actions bot commented Feb 28, 2026

Code Coverage

Package Line Rate Complexity Health
tempoch-core.src 99% 0
tempoch-ffi.src 67% 0
Summary 91% (1629 / 1791) 0

@VPRamon VPRamon merged commit 0c13a8b into main Feb 28, 2026
5 checks passed
@VPRamon VPRamon deleted the extend-ffi branch February 28, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant