| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
tempoch-cpp is a C++17 library for astronomical time primitives. It provides a header-only C++ API backed by the Rust tempoch-ffi engine (via a C FFI), with explicit time scales, explicit encodings, UTC civil conversion, and generic period operations.
The C++ wrapper intentionally mirrors the current tempoch-ffi surface. Rust-only features such as serde, tagged wrappers, and runtime-bundle refresh/context management are not exposed in tempoch-cpp yet.
git clone <repo-url>
cd tempoch-cpp
git submodule update --init tempoch
# Debian/RPM systems can install the official qtty-cpp package with:
./scripts/install-official-cpp-deps.sh
cmake -S . -B build
cmake --build build --parallel
ctest --test-dir build --output-on-failure
./build/01_quickstartFor local qtty-cpp development, install qtty-cpp to a staging prefix and pass it to CMake:
cmake -S . -B build -DCMAKE_PREFIX_PATH=/path/to/qtty-stage#include <iostream>
#include <qtty/qtty.hpp>
#include <tempoch/tempoch.hpp>
#include <tempoch/formats/jd.hpp>
#include <tempoch/formats/mjd.hpp>
#include <tempoch/scales/utc.hpp>
int main() {
using namespace tempoch;
CivilTime civil{2026, 7, 15, 22, 0, 0};
auto jd_tt = JulianDate<scale::TT>::from_utc(civil);
auto mjd_tt = ModifiedJulianDate<scale::TT>::from_jd(jd_tt);
auto utc = Time<scale::TT>::from_encoded(jd_tt).to<scale::UTC>();
auto jd_utc = utc.to<format::JD>();
std::cout << "Civil UTC : " << civil << "\n";
std::cout << "JD(TT) : " << jd_tt << "\n";
std::cout << "JD(UTC) : " << jd_utc << "\n";
std::cout << "MJD(TT) : " << mjd_tt << "\n";
Period observing_window(mjd_tt, mjd_tt + qtty::Hour(12.0));
std::cout << "Duration: " << observing_window.duration<qtty::Hour>() << "\n";
}Typed periods can be converted directly between scales and formats by applying the same conversion to both endpoints:
using namespace tempoch;
Period<EncodedTime<scale::UTC, format::JD>> window(
EncodedTime<scale::UTC, format::JD>(2460000.0),
EncodedTime<scale::UTC, format::JD>(2460001.0)
);
auto tt_mjd_window = window.to<scale::TT, format::MJD>();
UTCPeriod civil_window(
CivilTime(2026, 1, 1),
CivilTime(2026, 1, 2)
);
auto civil_tt_mjd_window = civil_window.to<scale::TT, format::MJD>();The public headers are now split by concept:
Time arithmetic uses qtty-cpp quantities. Subtracting two times returns a typed duration, and adding or subtracting a quantity shifts the time value.
auto jd0 = tempoch::JulianDate<tempoch::scale::TT>::J2000();
auto jd1 = jd0 + qtty::Hour(12.0);
auto dt = jd1 - jd0;
std::cout << dt.to<qtty::Hour>() << "\n";find_package(qtty_cpp 0.4.5 REQUIRED)
add_subdirectory(path/to/tempoch-cpp)
target_link_libraries(your_target PRIVATE tempoch_cpp)cmake --install buildfind_package(tempoch_cpp REQUIRED)
target_link_libraries(your_target PRIVATE tempoch::tempoch_cpp)This repository wraps the upstream tempoch project (git submodule in tempoch/). See tempoch/LICENSE for licensing details.
| Back | FazBrowse Home | New Git URL |