[#BloombergLP-bdlt-DatetimeInterval]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::DatetimeInterval
:relfileprefix: ../../
:mrdocs:

Each object of this class represents a (signed) time interval with microsecond resolution&period; See &lcub;The Representation of a Time Interval&rcub; for details&period;

== Synopsis

Declared in `&lt;bdlt&lowbar;datetimeinterval&period;h&gt;`

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlt/DatetimeInterval/2constructor-0f.adoc[`DatetimeInterval`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlt/DatetimeInterval/operator_assign.adoc[`operator&equals;`] 
| Assign to this object the value of the specified `rhs` time interval, and return a reference providing modifiable access to this object&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addDays.adoc[`addDays`] 
| Add the specified number of `days` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addDaysIfValid.adoc[`addDaysIfValid`] 
| Add the specified number of `days` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addHours.adoc[`addHours`] 
| Add the specified number of `hours` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addHoursIfValid.adoc[`addHoursIfValid`] 
| Add the specified number of `hours` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addInterval.adoc[`addInterval`] 
| Add the specified field values to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addIntervalIfValid.adoc[`addIntervalIfValid`] 
| Add the specified field values to this interval if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMicroseconds.adoc[`addMicroseconds`] 
| Add the specified number of `microseconds` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMicrosecondsIfValid.adoc[`addMicrosecondsIfValid`] 
| Add the specified number of `microseconds` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMilliseconds.adoc[`addMilliseconds`] 
| Add the specified number of `milliseconds` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMillisecondsIfValid.adoc[`addMillisecondsIfValid`] 
| Add the specified number of `milliseconds` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMinutes.adoc[`addMinutes`] 
| Add the specified number of `minutes` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addMinutesIfValid.adoc[`addMinutesIfValid`] 
| Add the specified number of `minutes` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addSeconds.adoc[`addSeconds`] 
| Add the specified number of `seconds` to this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/addSecondsIfValid.adoc[`addSecondsIfValid`] 
| Add the specified number of `seconds` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/bdexStreamIn.adoc[`bdexStreamIn`] 
| Assign to this object the value read from the specified input stream&period;
| xref:BloombergLP/bdlt/DatetimeInterval/bdexStreamOut.adoc[`bdexStreamOut`] 
| Write this object to the specified output stream using BDEX&period;
| xref:BloombergLP/bdlt/DatetimeInterval/days.adoc[`days`] 
| Return the days field of this time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/fractionalDayInMicroseconds.adoc[`fractionalDayInMicroseconds`] 
| Return the sub&hyphen;day portion of this interval in microseconds&period;
| xref:BloombergLP/bdlt/DatetimeInterval/hours.adoc[`hours`] 
| Return the hours field in the canonical representation of the value of this time interval&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/microseconds.adoc[`microseconds`] 
| Return the microseconds field in the canonical representation of the value of this time interval&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/milliseconds.adoc[`milliseconds`] 
| Return the milliseconds field in the canonical representation of the value of this time interval&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/minutes.adoc[`minutes`] 
| Return the minutes field in the canonical representation of the value of this time interval&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Add the specified `rhs` time interval to this object&period;
| xref:BloombergLP/bdlt/DatetimeInterval/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Subtract the specified `rhs` time interval from this object&period;
| xref:BloombergLP/bdlt/DatetimeInterval/print.adoc[`print`] 
| Write this object to the specified output stream in a human&hyphen;readable format&period;
| xref:BloombergLP/bdlt/DatetimeInterval/printToBuffer.adoc[`printToBuffer`] 
| Write a representation of this interval into the specified buffer&period;
| xref:BloombergLP/bdlt/DatetimeInterval/seconds.adoc[`seconds`] 
| Return the seconds field in the canonical representation of the value of this time interval&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setInterval.adoc[`setInterval`] 
| Set this time interval to the specified field values&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setIntervalIfValid.adoc[`setIntervalIfValid`] 
| Set this time interval to the specified field values if valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalDays.adoc[`setTotalDays`] 
| Set the overall value of this object to indicate the specified number of `days`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalHours.adoc[`setTotalHours`] 
| Set this interval to the specified total number of `hours`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalHoursIfValid.adoc[`setTotalHoursIfValid`] 
| Set this interval to the specified total `hours` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalMicroseconds.adoc[`setTotalMicroseconds`] 
| Set this interval to the specified total number of `microseconds`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalMilliseconds.adoc[`setTotalMilliseconds`] 
| Set this interval to the specified total number of `milliseconds`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalMillisecondsIfValid.adoc[`setTotalMillisecondsIfValid`] 
| Set this interval to the specified total `milliseconds` if valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalMinutes.adoc[`setTotalMinutes`] 
| Set this interval to the specified total number of `minutes`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalMinutesIfValid.adoc[`setTotalMinutesIfValid`] 
| Set this interval to the specified total `minutes` if valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalSeconds.adoc[`setTotalSeconds`] 
| Set this interval to the specified total number of `seconds`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsFromDouble.adoc[`setTotalSecondsFromDouble`] 
| Set this interval from a floating&hyphen;point total of `seconds`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsFromDoubleIfValid.adoc[`setTotalSecondsFromDoubleIfValid`] 
| Set this interval from floating&hyphen;point `seconds` if the result is valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsIfValid.adoc[`setTotalSecondsIfValid`] 
| Set this interval to the specified total `seconds` if valid&period;
| xref:BloombergLP/bdlt/DatetimeInterval/streamOut.adoc[`streamOut`] 
| Format this datetime interval to the specified output `stream`, and return a reference to `stream`&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalDays.adoc[`totalDays`] 
| Return this time interval in integral days, rounded toward 0&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalHours.adoc[`totalHours`] 
| Return the value of this time interval in integral hours, rounded toward 0&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalMicroseconds.adoc[`totalMicroseconds`] 
| Return this time interval as an integral number of microseconds&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalMilliseconds.adoc[`totalMilliseconds`] 
| Return the value of this time interval in integral milliseconds, rounded towards zero&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalMinutes.adoc[`totalMinutes`] 
| Return the value of this time interval in integral minutes, rounded toward 0&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalSeconds.adoc[`totalSeconds`] 
| Return the value of this time interval in integral seconds, rounded toward 0&period; Note that the return value may be negative&period;
| xref:BloombergLP/bdlt/DatetimeInterval/totalSecondsAsDouble.adoc[`totalSecondsAsDouble`] 
| Return this time interval in seconds as a floating&hyphen;point value&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlt/DatetimeInterval/isValid.adoc[`isValid`] 
| Return whether the given field values can form a valid time interval&period;
| xref:BloombergLP/bdlt/DatetimeInterval/maxSupportedBdexVersion-05.adoc[`maxSupportedBdexVersion`] 
| `maxSupportedBdexVersion` overloads
| xref:BloombergLP/bdlt/DatetimeInterval/maxSupportedVersion.adoc[`maxSupportedVersion`] 
| Return the most current BDEX streaming version number supported by this class&period;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlt/DatetimeInterval/k_MILLISECONDS_MAX.adoc[`k&lowbar;MILLISECONDS&lowbar;MAX`] 
| The maximum interval that is representable by a `DatetimeInterval`, in milliseconds&period;
| xref:BloombergLP/bdlt/DatetimeInterval/k_MILLISECONDS_MIN.adoc[`k&lowbar;MILLISECONDS&lowbar;MIN`] 
| The minimum interval that is representable by a `DatetimeInterval`, in milliseconds&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlt/hashAppend-00f.adoc[BloombergLP::bdlt::hashAppend]`
| Pass `object` to `hashAlg` for modular hashing&period;
| `xref:BloombergLP/bdlt/operator_ge-071.adoc[BloombergLP::bdlt::operator&gt;&equals;]`
| Return `true` if the specified `lhs` interval is greater than or equal to the specified `rhs` interval, and `false` otherwise&period;
| `xref:BloombergLP/bdlt/operator_gt-0f.adoc[BloombergLP::bdlt::operator&gt;]`
| Return `true` if the specified `lhs` interval is greater than the specified `rhs` interval, and `false` otherwise&period;
| `xref:BloombergLP/bdlt/operator_le-0d.adoc[BloombergLP::bdlt::operator&lt;&equals;]`
| Return `true` if the specified `lhs` interval is less than or equal to the specified `rhs` interval, and `false` otherwise&period;
| `xref:BloombergLP/bdlt/operator_lt-04.adoc[BloombergLP::bdlt::operator&lt;]`
| Return `true` if the specified `lhs` interval is less than `rhs`&period;
| `xref:BloombergLP/bdlt/operator_not_eq-0a3.adoc[BloombergLP::bdlt::operator!&equals;]`
| Return `true` if the specified `lhs` and `rhs` intervals are not equal&period;
| `xref:BloombergLP/bdlt/operator_eq-043.adoc[BloombergLP::bdlt::operator&equals;&equals;]`
| Return `true` if the specified `lhs` and `rhs` intervals are equal&period;
| `xref:BloombergLP/bdlt/operator_minus-01.adoc[BloombergLP::bdlt::operator&hyphen;]`
| Return a `DatetimeInterval` object whose value is the negative of the specified time interval `value`&period; The behavior is undefined unless `INT&lowbar;MIN &lt; value&period;days()`&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlt/operator_plus-087.adoc[`operator&plus;`]
| Return the sum of a datetime interval and a datetime&period;
| xref:BloombergLP/bdlt/operator_plus-0b.adoc[`operator&plus;`]
| Return a `Time` value that is the sum of the specified `lhs` datetime interval and the specified `rhs` time&period;
| xref:BloombergLP/bdlt/operator_plus-0d.adoc[`operator&plus;`]
| Return the sum of the specified `lhs` and `rhs` time intervals&period;
| xref:BloombergLP/bdlt/operator_minus-003.adoc[`operator&hyphen;`]
| Return a `DatetimeInterval` object initialized with the difference between the specified `lhs` and `rhs` time values&period;
| xref:BloombergLP/bdlt/operator_minus-0c.adoc[`operator&hyphen;`]
| Return the interval between two datetimes&period;
| xref:BloombergLP/bdlt/operator_minus-0f.adoc[`operator&hyphen;`]
| Return the difference between the specified `lhs` and `rhs` intervals&period;
|===


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