[#BloombergLP-bdlt-Datetime] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::Datetime :relfileprefix: ../../ :mrdocs: Value‐semantic type representing a date and a time of day. == Synopsis Declared in `<bdlt_datetime.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Datetime; ---- == Description This class implements a simply‐constrained value‐semantic type representing the composition of date and time values. Valid date values for the "date" part of a `Datetime` object are the same as those defined for `Date` objects; similarly, valid time values for the "time" part of a `Datetime` object are similar to those defined for `Time` objects (but with additional precision). Relational operators are disallowed on `Datetime` objects whose "time" part has the same value as that of a default constructed `Time` object. == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/Datetime/2constructor-0f.adoc[`Datetime`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlt/Datetime/operator_assign.adoc[`operator=`] | Assign to this object the value of the specified `rhs` object, and return a reference providing modifiable access to this object. | xref:BloombergLP/bdlt/Datetime/addDays.adoc[`addDays`] | Add the specified number of days to this datetime. | xref:BloombergLP/bdlt/Datetime/addDaysIfValid.adoc[`addDaysIfValid`] | Add days if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addHours.adoc[`addHours`] | Add the specified number of hours to this datetime. | xref:BloombergLP/bdlt/Datetime/addHoursIfValid.adoc[`addHoursIfValid`] | Add hours if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addMicroseconds.adoc[`addMicroseconds`] | Add the specified number of microseconds to this datetime. | xref:BloombergLP/bdlt/Datetime/addMicrosecondsIfValid.adoc[`addMicrosecondsIfValid`] | Add microseconds if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addMilliseconds.adoc[`addMilliseconds`] | Add the specified number of milliseconds to this datetime. | xref:BloombergLP/bdlt/Datetime/addMillisecondsIfValid.adoc[`addMillisecondsIfValid`] | Add milliseconds if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addMinutes.adoc[`addMinutes`] | Add the specified number of minutes to this datetime. | xref:BloombergLP/bdlt/Datetime/addMinutesIfValid.adoc[`addMinutesIfValid`] | Add minutes if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addSeconds.adoc[`addSeconds`] | Add the specified number of seconds to this datetime. | xref:BloombergLP/bdlt/Datetime/addSecondsIfValid.adoc[`addSecondsIfValid`] | Add seconds if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/addTime.adoc[`addTime`] | Add the specified time components to this datetime. | xref:BloombergLP/bdlt/Datetime/addTimeIfValid.adoc[`addTimeIfValid`] | Add time components if the result remains a valid datetime. | xref:BloombergLP/bdlt/Datetime/bdexStreamIn.adoc[`bdexStreamIn`] | Assign to this object the value read from the specified stream. | xref:BloombergLP/bdlt/Datetime/bdexStreamOut.adoc[`bdexStreamOut`] | Write this object to the specified output stream. | xref:BloombergLP/bdlt/Datetime/date.adoc[`date`] | Return the value of the "date" part of this object. | xref:BloombergLP/bdlt/Datetime/day.adoc[`day`] | Return the value of the `day` (of the month) attribute of this object. | xref:BloombergLP/bdlt/Datetime/dayOfWeek.adoc[`dayOfWeek`] | Return the value of the `dayOfWeek` attribute associated with the `day` (of the month) attribute of this object. | xref:BloombergLP/bdlt/Datetime/dayOfYear.adoc[`dayOfYear`] | Return the value of the `dayOfYear` attribute of this object. | xref:BloombergLP/bdlt/Datetime/getTime.adoc[`getTime`] | Load this object's time attributes into the specified addresses. | xref:BloombergLP/bdlt/Datetime/hour.adoc[`hour`] | Return the value of the `hour` attribute of this object. | xref:BloombergLP/bdlt/Datetime/microsecond.adoc[`microsecond`] | Return the value of the `microsecond` attribute of this object. | xref:BloombergLP/bdlt/Datetime/millisecond.adoc[`millisecond`] | Return the value of the `millisecond` attribute of this object. | xref:BloombergLP/bdlt/Datetime/minute.adoc[`minute`] | Return the value of the `minute` attribute of this object. | xref:BloombergLP/bdlt/Datetime/month.adoc[`month`] | Return the value of the `month` attribute of this object. | xref:BloombergLP/bdlt/Datetime/operator_plus_eq-0a.adoc[`operator+=`] | Addition assignment operators | xref:BloombergLP/bdlt/Datetime/operator_minus_eq-0e.adoc[`operator‐=`] | Subtraction assignment operators | xref:BloombergLP/bdlt/Datetime/print.adoc[`print`] | Write this object to the specified output stream in a readable form. | xref:BloombergLP/bdlt/Datetime/printToBuffer.adoc[`printToBuffer`] | Write a textual representation of this object into `result`. | xref:BloombergLP/bdlt/Datetime/second.adoc[`second`] | Return the value of the `second` attribute of this object. | xref:BloombergLP/bdlt/Datetime/setDate.adoc[`setDate`] | Set the "date" part of this object to have the value of the specified `date`. Note that this method has no effect on the "time" part of this object. | xref:BloombergLP/bdlt/Datetime/setDatetime-0f.adoc[`setDatetime`] | `setDatetime` overloads | xref:BloombergLP/bdlt/Datetime/setDatetimeIfValid-03.adoc[`setDatetimeIfValid`] | `setDatetimeIfValid` overloads | xref:BloombergLP/bdlt/Datetime/setHour.adoc[`setHour`] | Set the hour attribute of this object. | xref:BloombergLP/bdlt/Datetime/setHourIfValid.adoc[`setHourIfValid`] | Set the hour attribute if it is in range. | xref:BloombergLP/bdlt/Datetime/setMicrosecond.adoc[`setMicrosecond`] | Set the microsecond attribute of this object. | xref:BloombergLP/bdlt/Datetime/setMicrosecondIfValid.adoc[`setMicrosecondIfValid`] | Set the microsecond attribute if it is in range. | xref:BloombergLP/bdlt/Datetime/setMillisecond.adoc[`setMillisecond`] | Set the millisecond attribute of this object. | xref:BloombergLP/bdlt/Datetime/setMillisecondIfValid.adoc[`setMillisecondIfValid`] | Set the millisecond attribute if it is in range. | xref:BloombergLP/bdlt/Datetime/setMinute.adoc[`setMinute`] | Set the minute attribute of this object. | xref:BloombergLP/bdlt/Datetime/setMinuteIfValid.adoc[`setMinuteIfValid`] | Set the minute attribute if it is in range. | xref:BloombergLP/bdlt/Datetime/setSecond.adoc[`setSecond`] | Set the second attribute of this object. | xref:BloombergLP/bdlt/Datetime/setSecondIfValid.adoc[`setSecondIfValid`] | Set the second attribute if it is in range. | xref:BloombergLP/bdlt/Datetime/setTime-09.adoc[`setTime`] | `setTime` overloads | xref:BloombergLP/bdlt/Datetime/setTimeIfValid.adoc[`setTimeIfValid`] | Set the time part from fields if they form a valid time. | xref:BloombergLP/bdlt/Datetime/setYearDay.adoc[`setYearDay`] | Set the date part from `year` and `dayOfYear`. | xref:BloombergLP/bdlt/Datetime/setYearDayIfValid.adoc[`setYearDayIfValid`] | Set the date from `year` and `dayOfYear` if they form a valid date. | xref:BloombergLP/bdlt/Datetime/setYearMonthDay.adoc[`setYearMonthDay`] | Set the date part from `year`, `month`, and `day`. | xref:BloombergLP/bdlt/Datetime/setYearMonthDayIfValid.adoc[`setYearMonthDayIfValid`] | Set the date from year/month/day if they form a valid date. | xref:BloombergLP/bdlt/Datetime/streamOut.adoc[`streamOut`] | Format this datetime to the specified output `stream` and return a reference to the modifiable `stream`. | xref:BloombergLP/bdlt/Datetime/time.adoc[`time`] | Return the value of the "time" part of this object. | xref:BloombergLP/bdlt/Datetime/validateAndSetDatetime.adoc[`validateAndSetDatetime`] | Set this object from calendar fields if they form a valid datetime. | xref:BloombergLP/bdlt/Datetime/year.adoc[`year`] | Return the value of the `year` attribute of this object. |=== == Static Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/Datetime/isValid.adoc[`isValid`] | Return `true` if the specified attributes represent a valid `Datetime`. | xref:BloombergLP/bdlt/Datetime/maxSupportedBdexVersion-04.adoc[`maxSupportedBdexVersion`] | `maxSupportedBdexVersion` overloads | xref:BloombergLP/bdlt/Datetime/maxSupportedVersion.adoc[`maxSupportedVersion`] | Return the most current BDEX streaming version number supported by this class. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlt/hashAppend-01.adoc[BloombergLP::bdlt::hashAppend]` | Invoke the specified `hashAlg` on the specified `object`. | `xref:BloombergLP/bdlt/operator_ge-03.adoc[BloombergLP::bdlt::operator>=]` | Return `true` if `lhs` is greater than or equal to `rhs`. | `xref:BloombergLP/bdlt/operator_gt-02.adoc[BloombergLP::bdlt::operator>]` | Return `true` if `lhs` is greater than `rhs`. | `xref:BloombergLP/bdlt/operator_le-01.adoc[BloombergLP::bdlt::operator<=]` | Return `true` if `lhs` is less than or equal to `rhs`. | `xref:BloombergLP/bdlt/operator_lt-0d.adoc[BloombergLP::bdlt::operator<]` | Return `true` if `lhs` is less than `rhs`. | `xref:BloombergLP/bdlt/operator_not_eq-02.adoc[BloombergLP::bdlt::operator!=]` | Return `true` if the two datetimes do not have the same value. | `xref:BloombergLP/bdlt/operator_eq-022.adoc[BloombergLP::bdlt::operator==]` | Return `true` if the two datetimes have the same value. | `xref:BloombergLP/bdlt/operator_minus-0c.adoc[BloombergLP::bdlt::operator‐]` | Return the interval between two datetimes. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/operator_plus-069.adoc[`operator+`] | Return the sum of a time interval and a datetime. | xref:BloombergLP/bdlt/operator_plus-07.adoc[`operator+`] | Return the sum of a datetime and a time interval. | xref:BloombergLP/bdlt/operator_plus-087.adoc[`operator+`] | Return the sum of a datetime interval and a datetime. | xref:BloombergLP/bdlt/operator_plus-09.adoc[`operator+`] | Return the sum of a datetime and a datetime interval. | xref:BloombergLP/bdlt/operator_minus-06.adoc[`operator‐`] | Return the difference of a datetime and a time interval. | xref:BloombergLP/bdlt/operator_minus-07.adoc[`operator‐`] | Return the difference of a datetime and a datetime interval. | xref:BloombergLP/bdlt/operator_lt-034.adoc[`operator<`] | Return `true` if datetime `lhs` is less than timetable transition `rhs`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#