[#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. See {The Representation of a Time Interval} for details. == Synopsis Declared in `<bdlt_datetimeinterval.h>` [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=`] | Assign to this object the value of the specified `rhs` time interval, and return a reference providing modifiable access to this object. | xref:BloombergLP/bdlt/DatetimeInterval/addDays.adoc[`addDays`] | Add the specified number of `days` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addDaysIfValid.adoc[`addDaysIfValid`] | Add the specified number of `days` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addHours.adoc[`addHours`] | Add the specified number of `hours` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addHoursIfValid.adoc[`addHoursIfValid`] | Add the specified number of `hours` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addInterval.adoc[`addInterval`] | Add the specified field values to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addIntervalIfValid.adoc[`addIntervalIfValid`] | Add the specified field values to this interval if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addMicroseconds.adoc[`addMicroseconds`] | Add the specified number of `microseconds` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addMicrosecondsIfValid.adoc[`addMicrosecondsIfValid`] | Add the specified number of `microseconds` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addMilliseconds.adoc[`addMilliseconds`] | Add the specified number of `milliseconds` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addMillisecondsIfValid.adoc[`addMillisecondsIfValid`] | Add the specified number of `milliseconds` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addMinutes.adoc[`addMinutes`] | Add the specified number of `minutes` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addMinutesIfValid.adoc[`addMinutesIfValid`] | Add the specified number of `minutes` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/addSeconds.adoc[`addSeconds`] | Add the specified number of `seconds` to this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/addSecondsIfValid.adoc[`addSecondsIfValid`] | Add the specified number of `seconds` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/bdexStreamIn.adoc[`bdexStreamIn`] | Assign to this object the value read from the specified input stream. | xref:BloombergLP/bdlt/DatetimeInterval/bdexStreamOut.adoc[`bdexStreamOut`] | Write this object to the specified output stream using BDEX. | xref:BloombergLP/bdlt/DatetimeInterval/days.adoc[`days`] | Return the days field of this time interval. | xref:BloombergLP/bdlt/DatetimeInterval/fractionalDayInMicroseconds.adoc[`fractionalDayInMicroseconds`] | Return the sub‐day portion of this interval in microseconds. | xref:BloombergLP/bdlt/DatetimeInterval/hours.adoc[`hours`] | Return the hours field in the canonical representation of the value of this time interval. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/microseconds.adoc[`microseconds`] | Return the microseconds field in the canonical representation of the value of this time interval. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/milliseconds.adoc[`milliseconds`] | Return the milliseconds field in the canonical representation of the value of this time interval. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/minutes.adoc[`minutes`] | Return the minutes field in the canonical representation of the value of this time interval. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/operator_plus_eq.adoc[`operator+=`] | Add the specified `rhs` time interval to this object. | xref:BloombergLP/bdlt/DatetimeInterval/operator_minus_eq.adoc[`operator‐=`] | Subtract the specified `rhs` time interval from this object. | xref:BloombergLP/bdlt/DatetimeInterval/print.adoc[`print`] | Write this object to the specified output stream in a human‐readable format. | xref:BloombergLP/bdlt/DatetimeInterval/printToBuffer.adoc[`printToBuffer`] | Write a representation of this interval into the specified buffer. | xref:BloombergLP/bdlt/DatetimeInterval/seconds.adoc[`seconds`] | Return the seconds field in the canonical representation of the value of this time interval. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/setInterval.adoc[`setInterval`] | Set this time interval to the specified field values. | xref:BloombergLP/bdlt/DatetimeInterval/setIntervalIfValid.adoc[`setIntervalIfValid`] | Set this time interval to the specified field values if valid. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalDays.adoc[`setTotalDays`] | Set the overall value of this object to indicate the specified number of `days`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalHours.adoc[`setTotalHours`] | Set this interval to the specified total number of `hours`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalHoursIfValid.adoc[`setTotalHoursIfValid`] | Set this interval to the specified total `hours` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalMicroseconds.adoc[`setTotalMicroseconds`] | Set this interval to the specified total number of `microseconds`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalMilliseconds.adoc[`setTotalMilliseconds`] | Set this interval to the specified total number of `milliseconds`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalMillisecondsIfValid.adoc[`setTotalMillisecondsIfValid`] | Set this interval to the specified total `milliseconds` if valid. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalMinutes.adoc[`setTotalMinutes`] | Set this interval to the specified total number of `minutes`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalMinutesIfValid.adoc[`setTotalMinutesIfValid`] | Set this interval to the specified total `minutes` if valid. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalSeconds.adoc[`setTotalSeconds`] | Set this interval to the specified total number of `seconds`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsFromDouble.adoc[`setTotalSecondsFromDouble`] | Set this interval from a floating‐point total of `seconds`. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsFromDoubleIfValid.adoc[`setTotalSecondsFromDoubleIfValid`] | Set this interval from floating‐point `seconds` if the result is valid. | xref:BloombergLP/bdlt/DatetimeInterval/setTotalSecondsIfValid.adoc[`setTotalSecondsIfValid`] | Set this interval to the specified total `seconds` if valid. | xref:BloombergLP/bdlt/DatetimeInterval/streamOut.adoc[`streamOut`] | Format this datetime interval to the specified output `stream`, and return a reference to `stream`. | xref:BloombergLP/bdlt/DatetimeInterval/totalDays.adoc[`totalDays`] | Return this time interval in integral days, rounded toward 0. | xref:BloombergLP/bdlt/DatetimeInterval/totalHours.adoc[`totalHours`] | Return the value of this time interval in integral hours, rounded toward 0. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/totalMicroseconds.adoc[`totalMicroseconds`] | Return this time interval as an integral number of microseconds. | xref:BloombergLP/bdlt/DatetimeInterval/totalMilliseconds.adoc[`totalMilliseconds`] | Return the value of this time interval in integral milliseconds, rounded towards zero. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/totalMinutes.adoc[`totalMinutes`] | Return the value of this time interval in integral minutes, rounded toward 0. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/totalSeconds.adoc[`totalSeconds`] | Return the value of this time interval in integral seconds, rounded toward 0. Note that the return value may be negative. | xref:BloombergLP/bdlt/DatetimeInterval/totalSecondsAsDouble.adoc[`totalSecondsAsDouble`] | Return this time interval in seconds as a floating‐point value. |=== == 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. | 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. |=== == Static Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/DatetimeInterval/k_MILLISECONDS_MAX.adoc[`k_MILLISECONDS_MAX`] | The maximum interval that is representable by a `DatetimeInterval`, in milliseconds. | xref:BloombergLP/bdlt/DatetimeInterval/k_MILLISECONDS_MIN.adoc[`k_MILLISECONDS_MIN`] | The minimum interval that is representable by a `DatetimeInterval`, in milliseconds. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlt/hashAppend-00f.adoc[BloombergLP::bdlt::hashAppend]` | Pass `object` to `hashAlg` for modular hashing. | `xref:BloombergLP/bdlt/operator_ge-071.adoc[BloombergLP::bdlt::operator>=]` | Return `true` if the specified `lhs` interval is greater than or equal to the specified `rhs` interval, and `false` otherwise. | `xref:BloombergLP/bdlt/operator_gt-0f.adoc[BloombergLP::bdlt::operator>]` | Return `true` if the specified `lhs` interval is greater than the specified `rhs` interval, and `false` otherwise. | `xref:BloombergLP/bdlt/operator_le-0d.adoc[BloombergLP::bdlt::operator<=]` | Return `true` if the specified `lhs` interval is less than or equal to the specified `rhs` interval, and `false` otherwise. | `xref:BloombergLP/bdlt/operator_lt-04.adoc[BloombergLP::bdlt::operator<]` | Return `true` if the specified `lhs` interval is less than `rhs`. | `xref:BloombergLP/bdlt/operator_not_eq-0a3.adoc[BloombergLP::bdlt::operator!=]` | Return `true` if the specified `lhs` and `rhs` intervals are not equal. | `xref:BloombergLP/bdlt/operator_eq-043.adoc[BloombergLP::bdlt::operator==]` | Return `true` if the specified `lhs` and `rhs` intervals are equal. | `xref:BloombergLP/bdlt/operator_minus-01.adoc[BloombergLP::bdlt::operator‐]` | Return a `DatetimeInterval` object whose value is the negative of the specified time interval `value`. The behavior is undefined unless `INT_MIN < value.days()`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/operator_plus-087.adoc[`operator+`] | Return the sum of a datetime interval and a datetime. | xref:BloombergLP/bdlt/operator_plus-0b.adoc[`operator+`] | Return a `Time` value that is the sum of the specified `lhs` datetime interval and the specified `rhs` time. | xref:BloombergLP/bdlt/operator_plus-0d.adoc[`operator+`] | Return the sum of the specified `lhs` and `rhs` time intervals. | xref:BloombergLP/bdlt/operator_minus-003.adoc[`operator‐`] | Return a `DatetimeInterval` object initialized with the difference between the specified `lhs` and `rhs` time values. | xref:BloombergLP/bdlt/operator_minus-0c.adoc[`operator‐`] | Return the interval between two datetimes. | xref:BloombergLP/bdlt/operator_minus-0f.adoc[`operator‐`] | Return the difference between the specified `lhs` and `rhs` intervals. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#