NDEVR
API Documentation
TimeSpan

Stores a time span, or difference between two times, with an optional start time. More...

Collaboration diagram for TimeSpan:
[legend]

Public Member Functions

constexpr TimeSpan ()
 Constructs an invalid TimeSpan with no start time and an invalid elapsed duration.
constexpr TimeSpan (const fltp08 elapsed_seconds)
 Constructs a TimeSpan from a duration in seconds with no start time.
constexpr TimeSpan (const sint08 elapsed_nano_seconds)
 Constructs a TimeSpan from a signed 64-bit nanosecond duration with no start time.
constexpr TimeSpan (const Time &start, const fltp08 &elapsed_seconds)
 Constructs a TimeSpan from a start time and an elapsed duration in seconds.
constexpr TimeSpan (const Time &start, const sint08 &elapsed_nano_seconds)
 Constructs a TimeSpan from a start time and an elapsed nanosecond duration.
 TimeSpan (const Time &start, const Time &end)
 Constructs a TimeSpan from a start and end time, computing the elapsed duration.
constexpr TimeSpan (const uint08 elapsed_nano_seconds)
 Constructs a TimeSpan from an unsigned 64-bit nanosecond duration with no start time.
constexpr TimeSpan (sint04 elapsed_nano_seconds)
 Constructs a TimeSpan from a signed 32-bit nanosecond duration with no start time.
constexpr TimeSpan (uint04 elapsed_nano_seconds)
 Constructs a TimeSpan from an unsigned 32-bit nanosecond duration with no start time.
bool contains (const Time &time) const
 Checks whether the given time falls within this time span.
sint08 elapsedDays () const
 Returns the elapsed duration in whole days, accounting for calendar boundaries.
constexpr fltp08 elapsedHours () const
 Returns the elapsed duration in hours.
template<class t_type = fltp08>
constexpr t_type elapsedMilliseconds () const
 Returns the elapsed duration in milliseconds.
constexpr fltp08 elapsedMinutes () const
 Returns the elapsed duration in minutes.
sint08 elapsedMonths () const
 Returns the elapsed duration in whole months, accounting for calendar boundaries.
constexpr sint08 elapsedNanoseconds () const
 Returns the elapsed duration in nanoseconds.
fltp08 elapsedPercent (Time time, bool clip_time) const
 Computes the percentage of elapsed time at a given point within this span.
constexpr fltp08 elapsedSeconds () const
 Returns the elapsed duration in seconds.
Time endTime () const
 Computes the end time by adding the elapsed duration to the start time.
String getTimeString (const StringView &format_string) const
 Formats the time span as a human-readable string using the given format.
constexpr bool operator!= (const TimeSpan &time) const
 Checks inequality of start time or elapsed duration.
constexpr TimeSpan operator* (const fltp08 &mult) const
 Multiplies the elapsed duration by a floating-point factor.
constexpr TimeSpan operator* (const sint08 &mult) const
 Multiplies the elapsed duration by an integer factor.
constexpr TimeSpanoperator*= (const fltp08 &mult)
 Multiplies the elapsed duration in place by a floating-point factor.
constexpr TimeSpanoperator*= (const sint08 &mult)
 Multiplies the elapsed duration in place by an integer factor.
constexpr TimeSpan operator+ (const TimeSpan &other) const
 Adds two time spans, combining their elapsed durations.
constexpr TimeSpanoperator+= (const TimeSpan &other)
 Adds another span's elapsed duration to this one in place.
constexpr TimeSpan operator- () const
 Negates the elapsed duration of this time span.
constexpr TimeSpan operator- (const TimeSpan &other) const
 Subtracts another span's elapsed duration from this one.
constexpr TimeSpanoperator-= (const TimeSpan &other)
 Subtracts another span's elapsed duration from this one in place.
constexpr TimeSpan operator/ (const fltp08 &den) const
 Divides the elapsed duration by a floating-point denominator.
constexpr TimeSpan operator/ (const sint08 &den) const
 Divides the elapsed duration by an integer denominator.
constexpr fltp08 operator/ (const TimeSpan &time_2) const
 Divides this span by another, returning the ratio of elapsed durations.
constexpr bool operator< (const TimeSpan &other) const
 Compares elapsed durations, ignoring start time.
constexpr bool operator<= (const TimeSpan &other) const
 Compares elapsed durations, ignoring start time.
constexpr bool operator== (const TimeSpan &time) const
 Checks equality of both start time and elapsed duration.
constexpr bool operator> (const TimeSpan &other) const
 Compares elapsed durations, ignoring start time.
constexpr bool operator>= (const TimeSpan &other) const
 Compares elapsed durations, ignoring start time.
constexpr void setElapsedHours (fltp08 elapsed_minutes)
 Sets the elapsed duration in hours.
constexpr void setElapsedMinutes (fltp08 elapsed_minutes)
 Sets the elapsed duration in minutes.
constexpr void setElapsedSeconds (fltp08 elapsed_seconds)
 Sets the elapsed duration in seconds.
constexpr void setEndTime (Time time)
 Sets the end time by recomputing the elapsed duration from the current start time.
constexpr void setStartTime (Time time)
 Sets the start time of this span without modifying the elapsed duration.
constexpr Time startTime () const
 Returns the start time of this span.

Protected Attributes

sint08 m_elapsed_time
 The elapsed duration in nanoseconds. Can be negative for past spans.
Time m_start_time
 The optional start time of this span. Invalid if not set.

Detailed Description

Stores a time span, or difference between two times, with an optional start time.


Note: timespans can be negative to represent times in the past from an optional start time or positive to represent a time in the future from a given start time.

Definition at line 45 of file TimeSpan.h.

Constructor & Destructor Documentation

◆ TimeSpan() [1/8]

TimeSpan::TimeSpan ( sint04 elapsed_nano_seconds)
inlineexplicitconstexpr

Constructs a TimeSpan from a signed 32-bit nanosecond duration with no start time.

Parameters
[in]elapsed_nano_secondsThe elapsed time in nanoseconds.

Definition at line 59 of file TimeSpan.h.

References m_elapsed_time, and m_start_time.

◆ TimeSpan() [2/8]

TimeSpan::TimeSpan ( const sint08 elapsed_nano_seconds)
inlineexplicitconstexpr

Constructs a TimeSpan from a signed 64-bit nanosecond duration with no start time.

Parameters
[in]elapsed_nano_secondsThe elapsed time in nanoseconds.

Definition at line 67 of file TimeSpan.h.

References m_elapsed_time, and m_start_time.

◆ TimeSpan() [3/8]

TimeSpan::TimeSpan ( uint04 elapsed_nano_seconds)
inlineexplicitconstexpr

Constructs a TimeSpan from an unsigned 32-bit nanosecond duration with no start time.

Parameters
[in]elapsed_nano_secondsThe elapsed time in nanoseconds.

Definition at line 75 of file TimeSpan.h.

References cast(), m_elapsed_time, and m_start_time.

◆ TimeSpan() [4/8]

TimeSpan::TimeSpan ( const uint08 elapsed_nano_seconds)
inlineexplicitconstexpr

Constructs a TimeSpan from an unsigned 64-bit nanosecond duration with no start time.

Parameters
[in]elapsed_nano_secondsThe elapsed time in nanoseconds.

Definition at line 83 of file TimeSpan.h.

References cast(), m_elapsed_time, and m_start_time.

◆ TimeSpan() [5/8]

TimeSpan::TimeSpan ( const fltp08 elapsed_seconds)
inlineexplicitconstexpr

Constructs a TimeSpan from a duration in seconds with no start time.

Parameters
[in]elapsed_secondsThe elapsed time in seconds.

Definition at line 91 of file TimeSpan.h.

References cast(), m_elapsed_time, and m_start_time.

◆ TimeSpan() [6/8]

TimeSpan::TimeSpan ( const Time & start,
const Time & end )
inline

Constructs a TimeSpan from a start and end time, computing the elapsed duration.

Parameters
[in]startThe start time.
[in]endThe end time.

Definition at line 100 of file TimeSpan.h.

References cast(), m_elapsed_time, and m_start_time.

◆ TimeSpan() [7/8]

TimeSpan::TimeSpan ( const Time & start,
const sint08 & elapsed_nano_seconds )
inlineconstexpr

Constructs a TimeSpan from a start time and an elapsed nanosecond duration.

Parameters
[in]startThe start time.
[in]elapsed_nano_secondsThe elapsed time in nanoseconds.

Definition at line 110 of file TimeSpan.h.

References m_elapsed_time, and m_start_time.

◆ TimeSpan() [8/8]

TimeSpan::TimeSpan ( const Time & start,
const fltp08 & elapsed_seconds )
inlineconstexpr

Constructs a TimeSpan from a start time and an elapsed duration in seconds.

Parameters
[in]startThe start time.
[in]elapsed_secondsThe elapsed time in seconds.

Definition at line 120 of file TimeSpan.h.

References cast(), m_elapsed_time, and m_start_time.

Member Function Documentation

◆ contains()

bool TimeSpan::contains ( const Time & time) const

Checks whether the given time falls within this time span.

Parameters
[in]timeThe time to test.
Returns
True if the time is within the span, false otherwise.

◆ elapsedDays()

sint08 TimeSpan::elapsedDays ( ) const

Returns the elapsed duration in whole days, accounting for calendar boundaries.

Returns
The number of elapsed days.

◆ elapsedHours()

fltp08 TimeSpan::elapsedHours ( ) const
inlinenodiscardconstexpr

Returns the elapsed duration in hours.

Returns
The elapsed time in hours, or Invalid if the span is invalid.

Definition at line 246 of file TimeSpan.h.

References cast(), IsInvalid(), and m_elapsed_time.

◆ elapsedMilliseconds()

template<class t_type = fltp08>
t_type TimeSpan::elapsedMilliseconds ( ) const
inlinenodiscardconstexpr

Returns the elapsed duration in milliseconds.

Returns
The elapsed time in milliseconds, or Invalid if the span is invalid.

Definition at line 225 of file TimeSpan.h.

References cast(), IsInvalid(), and m_elapsed_time.

◆ elapsedMinutes()

fltp08 TimeSpan::elapsedMinutes ( ) const
inlinenodiscardconstexpr

Returns the elapsed duration in minutes.

Returns
The elapsed time in minutes, or Invalid if the span is invalid.

Definition at line 236 of file TimeSpan.h.

References cast(), IsInvalid(), and m_elapsed_time.

◆ elapsedMonths()

sint08 TimeSpan::elapsedMonths ( ) const

Returns the elapsed duration in whole months, accounting for calendar boundaries.

Returns
The number of elapsed months.

◆ elapsedNanoseconds()

sint08 TimeSpan::elapsedNanoseconds ( ) const
inlinenodiscardconstexpr

Returns the elapsed duration in nanoseconds.

Returns
The elapsed time in nanoseconds.

Definition at line 204 of file TimeSpan.h.

References m_elapsed_time.

Referenced by operator%().

◆ elapsedPercent()

fltp08 TimeSpan::elapsedPercent ( Time time,
bool clip_time ) const

Computes the percentage of elapsed time at a given point within this span.

Parameters
[in]timeThe time to evaluate.
[in]clip_timeWhether to clamp the result to the [0, 1] range.
Returns
The elapsed percentage as a value typically between 0.0 and 1.0.

◆ elapsedSeconds()

fltp08 TimeSpan::elapsedSeconds ( ) const
inlinenodiscardconstexpr

Returns the elapsed duration in seconds.

Returns
The elapsed time in seconds, or Invalid if the span is invalid.

Definition at line 213 of file TimeSpan.h.

References cast(), IsInvalid(), and m_elapsed_time.

Referenced by HardwareCommandQueue< t_type >::getCommandCSVInfo(), HardwareCommandQueue< t_type >::getCommandJSONInfo(), RealSenseMotor::update(), and LineEditResourceSetter< TimeSpan, ObjectInfo< TimeSpan >::Number >::ValueToFloat().

◆ endTime()

Time TimeSpan::endTime ( ) const
nodiscard

Computes the end time by adding the elapsed duration to the start time.

Returns
The end time of this span.

◆ getTimeString()

String TimeSpan::getTimeString ( const StringView & format_string) const

Formats the time span as a human-readable string using the given format.

Parameters
[in]format_stringThe format pattern to use for string conversion.
Returns
A formatted string representation of this time span.

◆ operator!=()

bool TimeSpan::operator!= ( const TimeSpan & time) const
inlineconstexpr

Checks inequality of start time or elapsed duration.

Parameters
[in]timeThe other TimeSpan to compare against.
Returns
True if the spans differ in start time or elapsed duration.

Definition at line 277 of file TimeSpan.h.

References TimeSpan(), m_elapsed_time, and m_start_time.

◆ operator*() [1/2]

TimeSpan TimeSpan::operator* ( const fltp08 & mult) const
inlineconstexpr

Multiplies the elapsed duration by a floating-point factor.

Parameters
[in]multThe floating-point multiplier.
Returns
A new TimeSpan with the scaled elapsed duration and the same start time.

Definition at line 361 of file TimeSpan.h.

References TimeSpan(), cast(), m_elapsed_time, and m_start_time.

◆ operator*() [2/2]

TimeSpan TimeSpan::operator* ( const sint08 & mult) const
inlineconstexpr

Multiplies the elapsed duration by an integer factor.

Parameters
[in]multThe integer multiplier.
Returns
A new TimeSpan with the scaled elapsed duration and the same start time.

Definition at line 352 of file TimeSpan.h.

References TimeSpan(), m_elapsed_time, and m_start_time.

◆ operator*=() [1/2]

TimeSpan & TimeSpan::operator*= ( const fltp08 & mult)
inlineconstexpr

Multiplies the elapsed duration in place by a floating-point factor.

Parameters
[in]multThe floating-point multiplier.
Returns
A reference to this TimeSpan after scaling.

Definition at line 380 of file TimeSpan.h.

References TimeSpan(), cast(), and m_elapsed_time.

◆ operator*=() [2/2]

TimeSpan & TimeSpan::operator*= ( const sint08 & mult)
inlineconstexpr

Multiplies the elapsed duration in place by an integer factor.

Parameters
[in]multThe integer multiplier.
Returns
A reference to this TimeSpan after scaling.

Definition at line 370 of file TimeSpan.h.

References TimeSpan(), cast(), and m_elapsed_time.

◆ operator+()

TimeSpan TimeSpan::operator+ ( const TimeSpan & other) const
inlineconstexpr

Adds two time spans, combining their elapsed durations.

Parameters
[in]otherThe TimeSpan to add.
Returns
A new TimeSpan with the combined elapsed duration.

Definition at line 390 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator+=()

TimeSpan & TimeSpan::operator+= ( const TimeSpan & other)
inlineconstexpr

Adds another span's elapsed duration to this one in place.

Parameters
[in]otherThe TimeSpan to add.
Returns
A reference to this TimeSpan after addition.

Definition at line 399 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator-() [1/2]

TimeSpan TimeSpan::operator- ( ) const
inlineconstexpr

Negates the elapsed duration of this time span.

Returns
A new TimeSpan with the negated elapsed duration.

Definition at line 417 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator-() [2/2]

TimeSpan TimeSpan::operator- ( const TimeSpan & other) const
inlineconstexpr

Subtracts another span's elapsed duration from this one.

Parameters
[in]otherThe TimeSpan to subtract.
Returns
A new TimeSpan with the difference in elapsed duration.

Definition at line 409 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator-=()

TimeSpan & TimeSpan::operator-= ( const TimeSpan & other)
inlineconstexpr

Subtracts another span's elapsed duration from this one in place.

Parameters
[in]otherThe TimeSpan to subtract.
Returns
A reference to this TimeSpan after subtraction.

Definition at line 426 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator/() [1/3]

TimeSpan TimeSpan::operator/ ( const fltp08 & den) const
inlineconstexpr

Divides the elapsed duration by a floating-point denominator.

Parameters
[in]denThe floating-point divisor.
Returns
A new TimeSpan with the divided elapsed duration and the same start time.

Definition at line 342 of file TimeSpan.h.

References TimeSpan(), cast(), m_elapsed_time, and m_start_time.

◆ operator/() [2/3]

TimeSpan TimeSpan::operator/ ( const sint08 & den) const
inlineconstexpr

Divides the elapsed duration by an integer denominator.

Parameters
[in]denThe integer divisor.
Returns
A new TimeSpan with the divided elapsed duration and the same start time.

Definition at line 333 of file TimeSpan.h.

References TimeSpan(), m_elapsed_time, and m_start_time.

◆ operator/() [3/3]

fltp08 TimeSpan::operator/ ( const TimeSpan & time_2) const
inlineconstexpr

Divides this span by another, returning the ratio of elapsed durations.

Parameters
[in]time_2The divisor TimeSpan.
Returns
The ratio of this span's elapsed time to the other's.

Definition at line 324 of file TimeSpan.h.

References TimeSpan(), cast(), and m_elapsed_time.

◆ operator<()

bool TimeSpan::operator< ( const TimeSpan & other) const
inlineconstexpr

Compares elapsed durations, ignoring start time.

Parameters
[in]otherThe other TimeSpan to compare against.
Returns
True if this span's elapsed duration is less.

Definition at line 305 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator<=()

bool TimeSpan::operator<= ( const TimeSpan & other) const
inlineconstexpr

Compares elapsed durations, ignoring start time.

Parameters
[in]otherThe other TimeSpan to compare against.
Returns
True if this span's elapsed duration is less or equal.

Definition at line 314 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator==()

bool TimeSpan::operator== ( const TimeSpan & time) const
inlineconstexpr

Checks equality of both start time and elapsed duration.

Parameters
[in]timeThe other TimeSpan to compare against.
Returns
True if both spans are identical.

Definition at line 267 of file TimeSpan.h.

References TimeSpan(), m_elapsed_time, and m_start_time.

◆ operator>()

bool TimeSpan::operator> ( const TimeSpan & other) const
inlineconstexpr

Compares elapsed durations, ignoring start time.

Parameters
[in]otherThe other TimeSpan to compare against.
Returns
True if this span's elapsed duration is greater.

Definition at line 287 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ operator>=()

bool TimeSpan::operator>= ( const TimeSpan & other) const
inlineconstexpr

Compares elapsed durations, ignoring start time.

Parameters
[in]otherThe other TimeSpan to compare against.
Returns
True if this span's elapsed duration is greater or equal.

Definition at line 296 of file TimeSpan.h.

References TimeSpan(), and m_elapsed_time.

◆ setElapsedHours()

void TimeSpan::setElapsedHours ( fltp08 elapsed_minutes)
inlineconstexpr

Sets the elapsed duration in hours.

Parameters
[in]elapsed_minutesThe new elapsed duration in hours.

Definition at line 183 of file TimeSpan.h.

References cast(), and m_elapsed_time.

◆ setElapsedMinutes()

void TimeSpan::setElapsedMinutes ( fltp08 elapsed_minutes)
inlineconstexpr

Sets the elapsed duration in minutes.

Parameters
[in]elapsed_minutesThe new elapsed duration in minutes.

Definition at line 175 of file TimeSpan.h.

References cast(), and m_elapsed_time.

◆ setElapsedSeconds()

void TimeSpan::setElapsedSeconds ( fltp08 elapsed_seconds)
inlineconstexpr

Sets the elapsed duration in seconds.

Parameters
[in]elapsed_secondsThe new elapsed duration in seconds.

Definition at line 167 of file TimeSpan.h.

References cast(), and m_elapsed_time.

◆ setEndTime()

void TimeSpan::setEndTime ( Time time)
inlineconstexpr

Sets the end time by recomputing the elapsed duration from the current start time.

Parameters
[in]timeThe new end time.

Definition at line 159 of file TimeSpan.h.

References Time::getNanoSeconds(), m_elapsed_time, and m_start_time.

◆ setStartTime()

void TimeSpan::setStartTime ( Time time)
inlineconstexpr

Sets the start time of this span without modifying the elapsed duration.

Parameters
[in]timeThe new start time.

Definition at line 151 of file TimeSpan.h.

References m_start_time.

◆ startTime()

Time TimeSpan::startTime ( ) const
inlinenodiscardconstexpr

Returns the start time of this span.

Returns
The start time, or an invalid Time if none was set.

Definition at line 143 of file TimeSpan.h.

References m_start_time.


The documentation for this class was generated from the following file: