Skip to content

feat: add precise integer time (TimeDuration, TimeStamp) - #31

Merged
adamek727 merged 1 commit into
mainfrom
feat/precise-time
Jun 17, 2026
Merged

feat: add precise integer time (TimeDuration, TimeStamp)#31
adamek727 merged 1 commit into
mainfrom
feat/precise-time

Conversation

@adamek727

Copy link
Copy Markdown
Owner

FUTURE_WORK v4.0.0 — first piece of the precise-time roadmap.

Opt-in utl/time_point.hpp adds two nanosecond-native (int64) wrappers over Time<int64_t>:

  • TimeDuration+, -, unary -, integer scaling *//, comparisons; ns()/us()/ms()/s() integer accessors; to_time() -> Time<double> seconds bridge; nanoseconds/microseconds/milliseconds/seconds factories.
  • TimeStamp — affine point: Stamp - Stamp -> TimeDuration, Stamp +/- TimeDuration -> Stamp, comparisons, and Stamp + Stamp deleted (adding absolute times is meaningless).

Per the agreed design: native integer mode, no inv()/sqrt/float ops, and it does not affect existing functionality — utl.hpp does not include it, so the float/double unit machinery and the single-header amalgamation are untouched. Absolute<Unit> was dropped as unnecessary.

New test t_time_point. Verified: build (Werror), 49 tests, clang-format, single-header --check in sync, mdbook; TimeStamp + TimeStamp confirmed rejected.

chrono interop is the next PR.

Add the opt-in header utl/time_point.hpp with TimeDuration and TimeStamp:
nanosecond-native int64 wrappers over Time<int64_t> with affine semantics
(TimeStamp - TimeStamp -> TimeDuration, TimeStamp +/- TimeDuration -> TimeStamp,
TimeStamp + TimeStamp deleted), scaling and comparison operators, the
nanoseconds/microseconds/milliseconds/seconds factories, and a to_time() bridge
to the dimensional Time<double> (seconds).

These types deliberately avoid inv()/sqrt/float division and are not pulled in
by utl.hpp, so the existing floating-point unit machinery and the single-header
amalgamation are unaffected. Documented in the user guide.

First piece of the v4.0.0 precise-time roadmap; chrono interop follows.
@adamek727
adamek727 merged commit 993e433 into main Jun 17, 2026
6 checks passed
@adamek727
adamek727 deleted the feat/precise-time branch June 17, 2026 07:51
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