clockAfter function
Tree-sitter 0.25.10 clock_after for a normalized monotonic timespec.
Implementation
TSClock clockAfter(TSClock base, TSDuration duration) {
final wholeSeconds =
duration.microseconds ~/ BigInt.from(_microsecondsPerSecond);
final remainingNanoseconds =
(duration.microseconds % BigInt.from(_microsecondsPerSecond)).toInt() *
_nanosecondsPerMicrosecond;
var seconds = base.seconds + wholeSeconds;
var nanoseconds = base.nanoseconds + remainingNanoseconds;
if (nanoseconds >= _nanosecondsPerSecond) {
nanoseconds -= _nanosecondsPerSecond;
seconds += BigInt.one;
}
return TSClock._(seconds, nanoseconds);
}