Skip to content

Comments

feat: implement Time<S> class template and CivilTime struct; update t…#2

Merged
VPRamon merged 5 commits intomainfrom
time-scales
Feb 24, 2026
Merged

feat: implement Time<S> class template and CivilTime struct; update t…#2
VPRamon merged 5 commits intomainfrom
time-scales

Conversation

@VPRamon
Copy link
Member

@VPRamon VPRamon commented Feb 24, 2026

This pull request significantly refactors the time scale system in the tempoch C++ library to introduce a more extensible, trait-based approach for representing and converting between time scales. The main changes include replacing the old hardcoded time types and conversion logic with a generic Time<S> template, introducing scale tags and traits, and updating type aliases and documentation for clarity and extensibility.

The most important changes are:

1. Introduction of Scale Tags and Traits

  • Added a new scales.hpp header that defines time scale tag types (JDScale, MJDScale, UTCScale) and the TimeScaleTraits/TimeConvertTraits trait classes, enabling generic and extensible handling of time scales and conversions. This allows for easier addition of new time scales in the future.

2. Refactoring of Type Aliases and Documentation

  • Updated the main umbrella header tempoch.hpp to document and re-export the new Time<S> template and its aliases (JulianDate, MJD, CivilTime, UTC), and to include the new scales.hpp and reorganized headers.

3. Simplification of Time Type Definitions

  • Replaced the previous concrete classes for JulianDate, MJD, and UTC in time.hpp with type aliases to the generic Time<S> template, and moved all implementation to time_base.hpp and scales.hpp. This reduces code duplication and centralizes logic.

4. Period and Traits Adjustments

  • Updated Period<T> and its traits: clarified in period.hpp that TimeTraits<Time<S>> specializations are now provided automatically for all scale-based types, and provided a manual specialization for CivilTime. [1] [2]
  • Changed the definition of UTCPeriod to use Period<CivilTime> instead of Period<UTC>, reflecting the new canonical civil time type.

These changes modernize the codebase, improve extensibility for new time scales, and simplify the interface for users and maintainers.

@VPRamon VPRamon self-assigned this Feb 24, 2026
@VPRamon VPRamon merged commit 0b27c11 into main Feb 24, 2026
3 checks passed
@VPRamon VPRamon deleted the time-scales branch February 24, 2026 20:38
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