A time interval with nanosecond resolution.

Synopsis

Declared in <bsls_timeinterval.h>

class TimeInterval;

Description

Each instance of this value‐semantic type represents a time interval with nanosecond resolution. In the "canonical representation" of a time interval, the seconds field may have any 64‐bit signed integer value, with the nanoseconds field limited to the range [ ‐999,999,999..999,999,999 ], and with the additional constraint that the two fields are either both non‐negative or both non‐positive.

Member Functions

Name

Description

TimeInterval [constructor]

Constructors

operator=

Assign this interval from a real number of seconds.

addDays

Add the specified number of days to this time interval.

addDuration

Add the specified chrono duration to this time interval.

addHours

Add the specified number of hours to this time interval.

addInterval

Add seconds and optional nanoseconds to this interval.

addMicroseconds

Add the specified number of microseconds to this time interval.

addMilliseconds

Add the specified number of milliseconds to this time interval.

addMinutes

Add the specified number of minutes to this time interval.

addNanoseconds

Add the specified number of nanoseconds to this time interval.

addSeconds

Add the specified number of seconds to this time interval.

asDuration

Return this interval as a std::chrono::duration object.

bdexStreamIn

Assign this object from the specified BDEX input stream.

bdexStreamOut

Write this object to the specified BDEX output stream.

isInDurationRange

Return whether this interval fits in DURATION_TYPE.

nanoseconds

Return the nanoseconds field in the canonical representation of the value of this time interval.

operator+=

Addition assignment operators

operator‐=

Subtraction assignment operators

print

Write this object to the specified output stream.

seconds

Return the seconds field in the canonical representation of the value of this time interval.

setInterval

Set this interval from seconds and optional nanoseconds.

setIntervalRaw

Set this interval from a canonical seconds/`nanoseconds` pair.

setTotalDays

Set this interval to the specified total number of days.

setTotalHours

Set this interval to the specified total number of hours.

setTotalMicroseconds

Set the overall value of this object to indicate the specified integral number of microseconds. Note that microseconds may be negative.

setTotalMilliseconds

Set the overall value of this object to indicate the specified integral number of milliseconds. Note that milliseconds may be negative.

setTotalMinutes

Set this interval to the specified total number of minutes.

setTotalNanoseconds

Set the overall value of this object to indicate the specified integral number of nanoseconds. Note that nanoseconds may be negative.

setTotalSeconds

Set the overall value of this object to indicate the specified integral number of seconds. Note that seconds may be negative.

streamOut

Format this time to the specified output stream, and return a reference to the modifiable stream.

totalDays

Return the value of this time interval as an integral number of days, rounded towards zero. Note that the return value may be negative.

totalHours

Return the value of this time interval as an integral number of hours, rounded towards zero. Note that the return value may be negative.

totalMicroseconds

Return this interval as whole microseconds, rounded toward zero.

totalMilliseconds

Return this interval as whole milliseconds, rounded toward zero.

totalMinutes

Return the value of this time interval as an integral number of minutes, rounded towards zero. Note that the return value may be negative.

totalNanoseconds

Return this interval as whole nanoseconds.

totalSeconds

Return this interval as whole seconds, rounded toward zero.

totalSecondsAsDouble

Return this interval as a real number of seconds.

Static Member Functions

Name

Description

isValid

isValid overloads

maxSupportedBdexVersion

maxSupportedBdexVersion overloads

maxSupportedVersion

Return the most current BDEX streaming version number supported by this class.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs intervals are not equal.

operator!=

Same as the preceding overload.

operator""_h

Convert the specified hours literal to a TimeInterval.

operator""_min

Convert the specified minutes literal to a TimeInterval.

operator""_ms

Convert the specified milliseconds literal to a TimeInterval.

operator""_ns

Convert the specified nanoseconds literal to a TimeInterval.

operator""_s

Convert the specified seconds literal to a TimeInterval.

operator""_us

Convert the specified microseconds literal to a TimeInterval.

operator+

Return the sum of the specified lhs and rhs time intervals.

operator+

Same as the preceding overload.

operator+

Same as the preceding overload.

operator‐

Return a TimeInterval value that is the negative of the specified rhs time interval. The behavior is undefined unless LLONG_MIN != rhs.seconds().

operator‐

Return the difference between the specified lhs and rhs intervals.

operator‐

Same as the preceding overload.

operator‐

Same as the preceding overload.

operator<

Return true if the specified lhs interval is less than rhs.

operator<

Same as the preceding overload.

operator<=

Same as the preceding overload.

operator<=

Same as the preceding overload.

operator==

Same as the preceding overload.

operator==

Return true if the specified lhs and rhs intervals are equal.

operator>

Same as the preceding overload.

operator>

Same as the preceding overload.

operator>=

Same as the preceding overload.

operator>=

Same as the preceding overload.

::BloombergLP::bdlt::operator+

Return the sum of a time interval and a datetime.

Created with MrDocs