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

Value&hyphen;semantic type representing a date and a time of day&period;

== Synopsis

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

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

== Description

This class implements a simply&hyphen;constrained value&hyphen;semantic type representing the composition of date and time values&period; Valid date values for the &quot;date&quot; part of a `Datetime` object are the same as those defined for `Date` objects&semi; similarly, valid time values for the &quot;time&quot; part of a `Datetime` object are similar to those defined for `Time` objects (but with additional precision)&period; Relational operators are disallowed on `Datetime` objects whose &quot;time&quot; part has the same value as that of a default constructed `Time` object&period;

== 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&equals;`] 
| Assign to this object the value of the specified `rhs` object, and return a reference providing modifiable access to this object&period;
| xref:BloombergLP/bdlt/Datetime/addDays.adoc[`addDays`] 
| Add the specified number of days to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addDaysIfValid.adoc[`addDaysIfValid`] 
| Add days if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addHours.adoc[`addHours`] 
| Add the specified number of hours to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addHoursIfValid.adoc[`addHoursIfValid`] 
| Add hours if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMicroseconds.adoc[`addMicroseconds`] 
| Add the specified number of microseconds to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMicrosecondsIfValid.adoc[`addMicrosecondsIfValid`] 
| Add microseconds if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMilliseconds.adoc[`addMilliseconds`] 
| Add the specified number of milliseconds to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMillisecondsIfValid.adoc[`addMillisecondsIfValid`] 
| Add milliseconds if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMinutes.adoc[`addMinutes`] 
| Add the specified number of minutes to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addMinutesIfValid.adoc[`addMinutesIfValid`] 
| Add minutes if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addSeconds.adoc[`addSeconds`] 
| Add the specified number of seconds to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addSecondsIfValid.adoc[`addSecondsIfValid`] 
| Add seconds if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/addTime.adoc[`addTime`] 
| Add the specified time components to this datetime&period;
| xref:BloombergLP/bdlt/Datetime/addTimeIfValid.adoc[`addTimeIfValid`] 
| Add time components if the result remains a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/bdexStreamIn.adoc[`bdexStreamIn`] 
| Assign to this object the value read from the specified stream&period;
| xref:BloombergLP/bdlt/Datetime/bdexStreamOut.adoc[`bdexStreamOut`] 
| Write this object to the specified output stream&period;
| xref:BloombergLP/bdlt/Datetime/date.adoc[`date`] 
| Return the value of the &quot;date&quot; part of this object&period;
| xref:BloombergLP/bdlt/Datetime/day.adoc[`day`] 
| Return the value of the `day` (of the month) attribute of this object&period;
| 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&period;
| xref:BloombergLP/bdlt/Datetime/dayOfYear.adoc[`dayOfYear`] 
| Return the value of the `dayOfYear` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/getTime.adoc[`getTime`] 
| Load this object&apos;s time attributes into the specified addresses&period;
| xref:BloombergLP/bdlt/Datetime/hour.adoc[`hour`] 
| Return the value of the `hour` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/microsecond.adoc[`microsecond`] 
| Return the value of the `microsecond` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/millisecond.adoc[`millisecond`] 
| Return the value of the `millisecond` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/minute.adoc[`minute`] 
| Return the value of the `minute` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/month.adoc[`month`] 
| Return the value of the `month` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/operator_plus_eq-0a.adoc[`operator&plus;&equals;`] 
| Addition assignment operators
| xref:BloombergLP/bdlt/Datetime/operator_minus_eq-0e.adoc[`operator&hyphen;&equals;`] 
| Subtraction assignment operators
| xref:BloombergLP/bdlt/Datetime/print.adoc[`print`] 
| Write this object to the specified output stream in a readable form&period;
| xref:BloombergLP/bdlt/Datetime/printToBuffer.adoc[`printToBuffer`] 
| Write a textual representation of this object into `result`&period;
| xref:BloombergLP/bdlt/Datetime/second.adoc[`second`] 
| Return the value of the `second` attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/setDate.adoc[`setDate`] 
| Set the &quot;date&quot; part of this object to have the value of the specified `date`&period; Note that this method has no effect on the &quot;time&quot; part of this object&period;
| 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&period;
| xref:BloombergLP/bdlt/Datetime/setHourIfValid.adoc[`setHourIfValid`] 
| Set the hour attribute if it is in range&period;
| xref:BloombergLP/bdlt/Datetime/setMicrosecond.adoc[`setMicrosecond`] 
| Set the microsecond attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/setMicrosecondIfValid.adoc[`setMicrosecondIfValid`] 
| Set the microsecond attribute if it is in range&period;
| xref:BloombergLP/bdlt/Datetime/setMillisecond.adoc[`setMillisecond`] 
| Set the millisecond attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/setMillisecondIfValid.adoc[`setMillisecondIfValid`] 
| Set the millisecond attribute if it is in range&period;
| xref:BloombergLP/bdlt/Datetime/setMinute.adoc[`setMinute`] 
| Set the minute attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/setMinuteIfValid.adoc[`setMinuteIfValid`] 
| Set the minute attribute if it is in range&period;
| xref:BloombergLP/bdlt/Datetime/setSecond.adoc[`setSecond`] 
| Set the second attribute of this object&period;
| xref:BloombergLP/bdlt/Datetime/setSecondIfValid.adoc[`setSecondIfValid`] 
| Set the second attribute if it is in range&period;
| 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&period;
| xref:BloombergLP/bdlt/Datetime/setYearDay.adoc[`setYearDay`] 
| Set the date part from `year` and `dayOfYear`&period;
| xref:BloombergLP/bdlt/Datetime/setYearDayIfValid.adoc[`setYearDayIfValid`] 
| Set the date from `year` and `dayOfYear` if they form a valid date&period;
| xref:BloombergLP/bdlt/Datetime/setYearMonthDay.adoc[`setYearMonthDay`] 
| Set the date part from `year`, `month`, and `day`&period;
| xref:BloombergLP/bdlt/Datetime/setYearMonthDayIfValid.adoc[`setYearMonthDayIfValid`] 
| Set the date from year&sol;month&sol;day if they form a valid date&period;
| xref:BloombergLP/bdlt/Datetime/streamOut.adoc[`streamOut`] 
| Format this datetime to the specified output `stream` and return a reference to the modifiable `stream`&period;
| xref:BloombergLP/bdlt/Datetime/time.adoc[`time`] 
| Return the value of the &quot;time&quot; part of this object&period;
| xref:BloombergLP/bdlt/Datetime/validateAndSetDatetime.adoc[`validateAndSetDatetime`] 
| Set this object from calendar fields if they form a valid datetime&period;
| xref:BloombergLP/bdlt/Datetime/year.adoc[`year`] 
| Return the value of the `year` attribute of this object&period;
|===


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


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlt/hashAppend-01.adoc[BloombergLP::bdlt::hashAppend]`
| Invoke the specified `hashAlg` on the specified `object`&period;
| `xref:BloombergLP/bdlt/operator_ge-03.adoc[BloombergLP::bdlt::operator&gt;&equals;]`
| Return `true` if `lhs` is greater than or equal to `rhs`&period;
| `xref:BloombergLP/bdlt/operator_gt-02.adoc[BloombergLP::bdlt::operator&gt;]`
| Return `true` if `lhs` is greater than `rhs`&period;
| `xref:BloombergLP/bdlt/operator_le-01.adoc[BloombergLP::bdlt::operator&lt;&equals;]`
| Return `true` if `lhs` is less than or equal to `rhs`&period;
| `xref:BloombergLP/bdlt/operator_lt-0d.adoc[BloombergLP::bdlt::operator&lt;]`
| Return `true` if `lhs` is less than `rhs`&period;
| `xref:BloombergLP/bdlt/operator_not_eq-02.adoc[BloombergLP::bdlt::operator!&equals;]`
| Return `true` if the two datetimes do not have the same value&period;
| `xref:BloombergLP/bdlt/operator_eq-022.adoc[BloombergLP::bdlt::operator&equals;&equals;]`
| Return `true` if the two datetimes have the same value&period;
| `xref:BloombergLP/bdlt/operator_minus-0c.adoc[BloombergLP::bdlt::operator&hyphen;]`
| Return the interval between two datetimes&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlt/operator_plus-069.adoc[`operator&plus;`]
| Return the sum of a time interval and a datetime&period;
| xref:BloombergLP/bdlt/operator_plus-07.adoc[`operator&plus;`]
| Return the sum of a datetime and a time interval&period;
| 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-09.adoc[`operator&plus;`]
| Return the sum of a datetime and a datetime interval&period;
| xref:BloombergLP/bdlt/operator_minus-06.adoc[`operator&hyphen;`]
| Return the difference of a datetime and a time interval&period;
| xref:BloombergLP/bdlt/operator_minus-07.adoc[`operator&hyphen;`]
| Return the difference of a datetime and a datetime interval&period;
| xref:BloombergLP/bdlt/operator_lt-034.adoc[`operator&lt;`]
| Return `true` if datetime `lhs` is less than timetable transition `rhs`&period;
|===


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