[#BloombergLP-bsls-TimeInterval]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::TimeInterval
:relfileprefix: ../../
:mrdocs:

A time interval with nanosecond resolution&period;

== Synopsis

Declared in `&lt;bsls&lowbar;timeinterval&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class TimeInterval;
----

== Description

Each instance of this value&hyphen;semantic type represents a time interval with nanosecond resolution&period; In the &quot;canonical representation&quot; of a time interval, the `seconds` field may have any 64&hyphen;bit signed integer value, with the `nanoseconds` field limited to the range `&lsqb; &hyphen;999,999,999&period;&period;999,999,999 &rsqb;`, and with the additional constraint that the two fields are either both non&hyphen;negative or both non&hyphen;positive&period;

== 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&equals;`] 
| Assign this interval from a real number of seconds&period;
| xref:BloombergLP/bsls/TimeInterval/addDays.adoc[`addDays`] 
| Add the specified number of `days` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addDuration.adoc[`addDuration`] 
| Add the specified chrono `duration` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addHours.adoc[`addHours`] 
| Add the specified number of `hours` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addInterval.adoc[`addInterval`] 
| Add `seconds` and optional `nanoseconds` to this interval&period;
| xref:BloombergLP/bsls/TimeInterval/addMicroseconds.adoc[`addMicroseconds`] 
| Add the specified number of `microseconds` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addMilliseconds.adoc[`addMilliseconds`] 
| Add the specified number of `milliseconds` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addMinutes.adoc[`addMinutes`] 
| Add the specified number of `minutes` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addNanoseconds.adoc[`addNanoseconds`] 
| Add the specified number of `nanoseconds` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/addSeconds.adoc[`addSeconds`] 
| Add the specified number of `seconds` to this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/asDuration.adoc[`asDuration`] 
| Return this interval as a `std&colon;&colon;chrono&colon;&colon;duration` object&period;
| xref:BloombergLP/bsls/TimeInterval/bdexStreamIn.adoc[`bdexStreamIn`] 
| Assign this object from the specified BDEX input `stream`&period;
| xref:BloombergLP/bsls/TimeInterval/bdexStreamOut.adoc[`bdexStreamOut`] 
| Write this object to the specified BDEX output `stream`&period;
| xref:BloombergLP/bsls/TimeInterval/isInDurationRange.adoc[`isInDurationRange`] 
| Return whether this interval fits in `DURATION&lowbar;TYPE`&period;
| xref:BloombergLP/bsls/TimeInterval/nanoseconds.adoc[`nanoseconds`] 
| Return the nanoseconds field in the canonical representation of the value of this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/operator_plus_eq-02.adoc[`operator&plus;&equals;`] 
| Addition assignment operators
| xref:BloombergLP/bsls/TimeInterval/operator_minus_eq-0f.adoc[`operator&hyphen;&equals;`] 
| Subtraction assignment operators
| xref:BloombergLP/bsls/TimeInterval/print.adoc[`print`] 
| Write this object to the specified output `stream`&period;
| xref:BloombergLP/bsls/TimeInterval/seconds.adoc[`seconds`] 
| Return the seconds field in the canonical representation of the value of this time interval&period;
| xref:BloombergLP/bsls/TimeInterval/setInterval.adoc[`setInterval`] 
| Set this interval from `seconds` and optional `nanoseconds`&period;
| xref:BloombergLP/bsls/TimeInterval/setIntervalRaw.adoc[`setIntervalRaw`] 
| Set this interval from a canonical `seconds`&sol;`nanoseconds` pair&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalDays.adoc[`setTotalDays`] 
| Set this interval to the specified total number of `days`&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalHours.adoc[`setTotalHours`] 
| Set this interval to the specified total number of `hours`&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalMicroseconds.adoc[`setTotalMicroseconds`] 
| Set the overall value of this object to indicate the specified integral number of `microseconds`&period; Note that `microseconds` may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalMilliseconds.adoc[`setTotalMilliseconds`] 
| Set the overall value of this object to indicate the specified integral number of `milliseconds`&period; Note that `milliseconds` may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalMinutes.adoc[`setTotalMinutes`] 
| Set this interval to the specified total number of `minutes`&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalNanoseconds.adoc[`setTotalNanoseconds`] 
| Set the overall value of this object to indicate the specified integral number of `nanoseconds`&period; Note that `nanoseconds` may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/setTotalSeconds.adoc[`setTotalSeconds`] 
| Set the overall value of this object to indicate the specified integral number of `seconds`&period; Note that `seconds` may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/streamOut.adoc[`streamOut`] 
| Format this time to the specified output `stream`, and return a reference to the modifiable `stream`&period;
| xref:BloombergLP/bsls/TimeInterval/totalDays.adoc[`totalDays`] 
| Return the value of this time interval as an integral number of days, rounded towards zero&period; Note that the return value may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/totalHours.adoc[`totalHours`] 
| Return the value of this time interval as an integral number of hours, rounded towards zero&period; Note that the return value may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/totalMicroseconds.adoc[`totalMicroseconds`] 
| Return this interval as whole microseconds, rounded toward zero&period;
| xref:BloombergLP/bsls/TimeInterval/totalMilliseconds.adoc[`totalMilliseconds`] 
| Return this interval as whole milliseconds, rounded toward zero&period;
| xref:BloombergLP/bsls/TimeInterval/totalMinutes.adoc[`totalMinutes`] 
| Return the value of this time interval as an integral number of minutes, rounded towards zero&period; Note that the return value may be negative&period;
| xref:BloombergLP/bsls/TimeInterval/totalNanoseconds.adoc[`totalNanoseconds`] 
| Return this interval as whole nanoseconds&period;
| xref:BloombergLP/bsls/TimeInterval/totalSeconds.adoc[`totalSeconds`] 
| Return this interval as whole seconds, rounded toward zero&period;
| xref:BloombergLP/bsls/TimeInterval/totalSecondsAsDouble.adoc[`totalSecondsAsDouble`] 
| Return this interval as a real number of seconds&period;
|===


== 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&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bsls/operator_not_eq-05.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` intervals are not equal&period;
| xref:BloombergLP/bsls/operator_not_eq-0ba.adoc[`operator!&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_h.adoc[`operator&quot;&quot;&lowbar;h`]
| Convert the specified `hours` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_min.adoc[`operator&quot;&quot;&lowbar;min`]
| Convert the specified `minutes` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_ms.adoc[`operator&quot;&quot;&lowbar;ms`]
| Convert the specified `milliseconds` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_ns.adoc[`operator&quot;&quot;&lowbar;ns`]
| Convert the specified `nanoseconds` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_s.adoc[`operator&quot;&quot;&lowbar;s`]
| Convert the specified `seconds` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_us.adoc[`operator&quot;&quot;&lowbar;us`]
| Convert the specified `microseconds` literal to a `TimeInterval`&period;
| xref:BloombergLP/bsls/operator_plus-01.adoc[`operator&plus;`]
| Return the sum of the specified `lhs` and `rhs` time intervals&period;
| xref:BloombergLP/bsls/operator_plus-0ca.adoc[`operator&plus;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_plus-0cf.adoc[`operator&plus;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_minus-003.adoc[`operator&hyphen;`]
| Return a `TimeInterval` value that is the negative of the specified `rhs` time interval&period; The behavior is undefined unless `LLONG&lowbar;MIN !&equals; rhs&period;seconds()`&period;
| xref:BloombergLP/bsls/operator_minus-04.adoc[`operator&hyphen;`]
| Return the difference between the specified `lhs` and `rhs` intervals&period;
| xref:BloombergLP/bsls/operator_minus-0a.adoc[`operator&hyphen;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_minus-0e.adoc[`operator&hyphen;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_lt-01.adoc[`operator&lt;`]
| Return `true` if the specified `lhs` interval is less than `rhs`&period;
| xref:BloombergLP/bsls/operator_lt-022.adoc[`operator&lt;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_le-07.adoc[`operator&lt;&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_le-08.adoc[`operator&lt;&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_eq-0a.adoc[`operator&equals;&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_eq-0e.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` intervals are equal&period;
| xref:BloombergLP/bsls/operator_gt-02.adoc[`operator&gt;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_gt-06.adoc[`operator&gt;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_ge-05.adoc[`operator&gt;&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bsls/operator_ge-07.adoc[`operator&gt;&equals;`]
| Same as the preceding overload&period;
| xref:BloombergLP/bdlt/operator_plus-069.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlt&colon;&colon;operator&plus;`]
| Return the sum of a time interval and a datetime&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
