Skip to content

Generic Time#1

Merged
VPRamon merged 6 commits intomainfrom
cout
Feb 23, 2026
Merged

Generic Time#1
VPRamon merged 6 commits intomainfrom
cout

Conversation

@VPRamon
Copy link
Member

@VPRamon VPRamon commented Feb 23, 2026

This pull request introduces a major refactor of the Period class, making it a generic template that supports multiple time types (MJD, JulianDate, UTC) instead of only MJD. It also integrates the external qtty-cpp library to provide type-safe time quantities and unit conversions, and adds streaming operators for improved output formatting. The examples and tests have been updated to use the new generic API and to demonstrate unit conversions.

The most important changes are:

1. Period Class Refactor and Generalization

  • Refactored Period into a class template Period<T>, allowing periods to be expressed in MJD, JulianDate, or UTC, with conversions handled by new TimeTraits specializations. This removes ambiguity and makes the API more robust and flexible. (include/tempoch/period.hpp, examples/time_example.cpp, tests/test_period.cpp) [1] [2] [3] [4] [5]

2. Integration of qtty-cpp for Type-Safe Units

  • Added qtty-cpp as a submodule and linked it in the build system. The Period class now provides a duration() method that returns a qtty::Quantity and supports unit conversions (e.g., days, hours, seconds), improving type safety and clarity. (.gitmodules, CMakeLists.txt, include/tempoch/period.hpp, examples/time_example.cpp, tests/test_period.cpp, qtty-cpp) [1] [2] [3] [4] [5]

3. Improved Output Formatting

  • Added operator<< overloads for MJD, JulianDate, UTC, and generic Period<T> to enable direct and consistent streaming to output streams, simplifying example and test code. (include/tempoch/time.hpp, include/tempoch/period.hpp, examples/time_example.cpp) [1] [2] [3] [4]

4. Updates to Examples and Tests

  • Updated the example and test code to use the new generic Period<T> API, demonstrate unit conversions, and use the new streaming operators. Added new tests for duration in different units. (examples/time_example.cpp, tests/test_period.cpp) [1] [2] [3]

5. Build System and Dependency Updates

  • Modified CMakeLists.txt to add and link the qtty-cpp submodule, ensuring the new dependency is included in the build. (CMakeLists.txt, .gitmodules) [1] [2]

These changes make the time period API more expressive, type-safe, and easier to use, while improving output formatting and extensibility.

@VPRamon VPRamon self-assigned this Feb 23, 2026
VPRamon added 4 commits February 23, 2026 14:02
- Updated exception constructors in ffi_core.hpp for consistent formatting.
- Enhanced check_status function for better readability and structure.
- Rearranged include directives in period.hpp and tempoch.hpp for clarity.
- Improved formatting and consistency in time.hpp, including UTC, JulianDate, and MJD classes.
- Updated test cases in main.cpp, test_period.cpp, and test_time.cpp for consistent formatting and improved readability.
- Updated submodule reference for qtty-cpp.
@VPRamon VPRamon merged commit 69b60bd into main Feb 23, 2026
3 checks passed
@VPRamon VPRamon deleted the cout branch February 23, 2026 14:26
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