[#BloombergLP-bsls-TimeInterval] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::TimeInterval :relfileprefix: ../../ :mrdocs: A time interval with nanosecond resolution. == Synopsis Declared in `<bsls_timeinterval.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- 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 [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/TimeInterval/2constructor-01.adoc[`TimeInterval`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bsls/TimeInterval/operator_assign.adoc[`operator=`] | Assign this interval from a real number of seconds. | xref:BloombergLP/bsls/TimeInterval/addDays.adoc[`addDays`] | Add the specified number of `days` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addDuration.adoc[`addDuration`] | Add the specified chrono `duration` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addHours.adoc[`addHours`] | Add the specified number of `hours` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addInterval.adoc[`addInterval`] | Add `seconds` and optional `nanoseconds` to this interval. | xref:BloombergLP/bsls/TimeInterval/addMicroseconds.adoc[`addMicroseconds`] | Add the specified number of `microseconds` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addMilliseconds.adoc[`addMilliseconds`] | Add the specified number of `milliseconds` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addMinutes.adoc[`addMinutes`] | Add the specified number of `minutes` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addNanoseconds.adoc[`addNanoseconds`] | Add the specified number of `nanoseconds` to this time interval. | xref:BloombergLP/bsls/TimeInterval/addSeconds.adoc[`addSeconds`] | Add the specified number of `seconds` to this time interval. | xref:BloombergLP/bsls/TimeInterval/asDuration.adoc[`asDuration`] | Return this interval as a `std::chrono::duration` object. | xref:BloombergLP/bsls/TimeInterval/bdexStreamIn.adoc[`bdexStreamIn`] | Assign this object from the specified BDEX input `stream`. | xref:BloombergLP/bsls/TimeInterval/bdexStreamOut.adoc[`bdexStreamOut`] | Write this object to the specified BDEX output `stream`. | xref:BloombergLP/bsls/TimeInterval/isInDurationRange.adoc[`isInDurationRange`] | Return whether this interval fits in `DURATION_TYPE`. | xref:BloombergLP/bsls/TimeInterval/nanoseconds.adoc[`nanoseconds`] | Return the nanoseconds field in the canonical representation of the value of this time interval. | xref:BloombergLP/bsls/TimeInterval/operator_plus_eq-02.adoc[`operator+=`] | Addition assignment operators | xref:BloombergLP/bsls/TimeInterval/operator_minus_eq-0f.adoc[`operator‐=`] | Subtraction assignment operators | xref:BloombergLP/bsls/TimeInterval/print.adoc[`print`] | Write this object to the specified output `stream`. | xref:BloombergLP/bsls/TimeInterval/seconds.adoc[`seconds`] | Return the seconds field in the canonical representation of the value of this time interval. | xref:BloombergLP/bsls/TimeInterval/setInterval.adoc[`setInterval`] | Set this interval from `seconds` and optional `nanoseconds`. | xref:BloombergLP/bsls/TimeInterval/setIntervalRaw.adoc[`setIntervalRaw`] | Set this interval from a canonical `seconds`/`nanoseconds` pair. | xref:BloombergLP/bsls/TimeInterval/setTotalDays.adoc[`setTotalDays`] | Set this interval to the specified total number of `days`. | xref:BloombergLP/bsls/TimeInterval/setTotalHours.adoc[`setTotalHours`] | Set this interval to the specified total number of `hours`. | xref:BloombergLP/bsls/TimeInterval/setTotalMicroseconds.adoc[`setTotalMicroseconds`] | Set the overall value of this object to indicate the specified integral number of `microseconds`. Note that `microseconds` may be negative. | xref:BloombergLP/bsls/TimeInterval/setTotalMilliseconds.adoc[`setTotalMilliseconds`] | Set the overall value of this object to indicate the specified integral number of `milliseconds`. Note that `milliseconds` may be negative. | xref:BloombergLP/bsls/TimeInterval/setTotalMinutes.adoc[`setTotalMinutes`] | Set this interval to the specified total number of `minutes`. | xref:BloombergLP/bsls/TimeInterval/setTotalNanoseconds.adoc[`setTotalNanoseconds`] | Set the overall value of this object to indicate the specified integral number of `nanoseconds`. Note that `nanoseconds` may be negative. | xref:BloombergLP/bsls/TimeInterval/setTotalSeconds.adoc[`setTotalSeconds`] | Set the overall value of this object to indicate the specified integral number of `seconds`. Note that `seconds` may be negative. | xref:BloombergLP/bsls/TimeInterval/streamOut.adoc[`streamOut`] | Format this time to the specified output `stream`, and return a reference to the modifiable `stream`. | xref:BloombergLP/bsls/TimeInterval/totalDays.adoc[`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. | xref:BloombergLP/bsls/TimeInterval/totalHours.adoc[`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. | xref:BloombergLP/bsls/TimeInterval/totalMicroseconds.adoc[`totalMicroseconds`] | Return this interval as whole microseconds, rounded toward zero. | xref:BloombergLP/bsls/TimeInterval/totalMilliseconds.adoc[`totalMilliseconds`] | Return this interval as whole milliseconds, rounded toward zero. | xref:BloombergLP/bsls/TimeInterval/totalMinutes.adoc[`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. | xref:BloombergLP/bsls/TimeInterval/totalNanoseconds.adoc[`totalNanoseconds`] | Return this interval as whole nanoseconds. | xref:BloombergLP/bsls/TimeInterval/totalSeconds.adoc[`totalSeconds`] | Return this interval as whole seconds, rounded toward zero. | xref:BloombergLP/bsls/TimeInterval/totalSecondsAsDouble.adoc[`totalSecondsAsDouble`] | Return this interval as a real number of seconds. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/TimeInterval/isValid-07.adoc[`isValid`] | `isValid` overloads | xref:BloombergLP/bsls/TimeInterval/maxSupportedBdexVersion-00.adoc[`maxSupportedBdexVersion`] | `maxSupportedBdexVersion` overloads | xref:BloombergLP/bsls/TimeInterval/maxSupportedVersion.adoc[`maxSupportedVersion`] | Return the most current BDEX streaming version number supported by this class. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bsls/operator_not_eq-05.adoc[`operator!=`] | Return `true` if the specified `lhs` and `rhs` intervals are not equal. | xref:BloombergLP/bsls/operator_not_eq-0ba.adoc[`operator!=`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_h.adoc[`operator""_h`] | Convert the specified `hours` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_min.adoc[`operator""_min`] | Convert the specified `minutes` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_ms.adoc[`operator""_ms`] | Convert the specified `milliseconds` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_ns.adoc[`operator""_ns`] | Convert the specified `nanoseconds` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_s.adoc[`operator""_s`] | Convert the specified `seconds` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_us.adoc[`operator""_us`] | Convert the specified `microseconds` literal to a `TimeInterval`. | xref:BloombergLP/bsls/operator_plus-01.adoc[`operator+`] | Return the sum of the specified `lhs` and `rhs` time intervals. | xref:BloombergLP/bsls/operator_plus-0ca.adoc[`operator+`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_plus-0cf.adoc[`operator+`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_minus-003.adoc[`operator‐`] | Return a `TimeInterval` value that is the negative of the specified `rhs` time interval. The behavior is undefined unless `LLONG_MIN != rhs.seconds()`. | xref:BloombergLP/bsls/operator_minus-04.adoc[`operator‐`] | Return the difference between the specified `lhs` and `rhs` intervals. | xref:BloombergLP/bsls/operator_minus-0a.adoc[`operator‐`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_minus-0e.adoc[`operator‐`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_lt-01.adoc[`operator<`] | Return `true` if the specified `lhs` interval is less than `rhs`. | xref:BloombergLP/bsls/operator_lt-022.adoc[`operator<`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_le-07.adoc[`operator<=`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_le-08.adoc[`operator<=`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_eq-0a.adoc[`operator==`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_eq-0e.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` intervals are equal. | xref:BloombergLP/bsls/operator_gt-02.adoc[`operator>`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_gt-06.adoc[`operator>`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_ge-05.adoc[`operator>=`] | Same as the preceding overload. | xref:BloombergLP/bsls/operator_ge-07.adoc[`operator>=`] | Same as the preceding overload. | xref:BloombergLP/bdlt/operator_plus-069.adoc[`::BloombergLP::bdlt::operator+`] | Return the sum of a time interval and a datetime. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#