Value‐semantic type representing a date and a time of day.

Synopsis

Declared in <bdlt_datetime.h>

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

Name

Description

Datetime [constructor]

Constructors

operator=

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

addDays

Add the specified number of days to this datetime.

addDaysIfValid

Add days if the result remains a valid datetime.

addHours

Add the specified number of hours to this datetime.

addHoursIfValid

Add hours if the result remains a valid datetime.

addMicroseconds

Add the specified number of microseconds to this datetime.

addMicrosecondsIfValid

Add microseconds if the result remains a valid datetime.

addMilliseconds

Add the specified number of milliseconds to this datetime.

addMillisecondsIfValid

Add milliseconds if the result remains a valid datetime.

addMinutes

Add the specified number of minutes to this datetime.

addMinutesIfValid

Add minutes if the result remains a valid datetime.

addSeconds

Add the specified number of seconds to this datetime.

addSecondsIfValid

Add seconds if the result remains a valid datetime.

addTime

Add the specified time components to this datetime.

addTimeIfValid

Add time components if the result remains a valid datetime.

bdexStreamIn

Assign to this object the value read from the specified stream.

bdexStreamOut

Write this object to the specified output stream.

date

Return the value of the "date" part of this object.

day

Return the value of the day (of the month) attribute of this object.

dayOfWeek

Return the value of the dayOfWeek attribute associated with the day (of the month) attribute of this object.

dayOfYear

Return the value of the dayOfYear attribute of this object.

getTime

Load this object's time attributes into the specified addresses.

hour

Return the value of the hour attribute of this object.

microsecond

Return the value of the microsecond attribute of this object.

millisecond

Return the value of the millisecond attribute of this object.

minute

Return the value of the minute attribute of this object.

month

Return the value of the month attribute of this object.

operator+=

Addition assignment operators

operator‐=

Subtraction assignment operators

print

Write this object to the specified output stream in a readable form.

printToBuffer

Write a textual representation of this object into result.

second

Return the value of the second attribute of this object.

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.

setDatetime

setDatetime overloads

setDatetimeIfValid

setDatetimeIfValid overloads

setHour

Set the hour attribute of this object.

setHourIfValid

Set the hour attribute if it is in range.

setMicrosecond

Set the microsecond attribute of this object.

setMicrosecondIfValid

Set the microsecond attribute if it is in range.

setMillisecond

Set the millisecond attribute of this object.

setMillisecondIfValid

Set the millisecond attribute if it is in range.

setMinute

Set the minute attribute of this object.

setMinuteIfValid

Set the minute attribute if it is in range.

setSecond

Set the second attribute of this object.

setSecondIfValid

Set the second attribute if it is in range.

setTime

setTime overloads

setTimeIfValid

Set the time part from fields if they form a valid time.

setYearDay

Set the date part from year and dayOfYear.

setYearDayIfValid

Set the date from year and dayOfYear if they form a valid date.

setYearMonthDay

Set the date part from year, month, and day.

setYearMonthDayIfValid

Set the date from year/month/day if they form a valid date.

streamOut

Format this datetime to the specified output stream and return a reference to the modifiable stream.

time

Return the value of the "time" part of this object.

validateAndSetDatetime

Set this object from calendar fields if they form a valid datetime.

year

Return the value of the year attribute of this object.

Static Member Functions

Name

Description

isValid

Return true if the specified attributes represent a valid Datetime.

maxSupportedBdexVersion

maxSupportedBdexVersion overloads

maxSupportedVersion

Return the most current BDEX streaming version number supported by this class.

Friends

Name

Description

BloombergLP::bdlt::hashAppend

Invoke the specified hashAlg on the specified object.

BloombergLP::bdlt::operator>=

Return true if lhs is greater than or equal to rhs.

BloombergLP::bdlt::operator>

Return true if lhs is greater than rhs.

BloombergLP::bdlt::operator<=

Return true if lhs is less than or equal to rhs.

BloombergLP::bdlt::operator<

Return true if lhs is less than rhs.

BloombergLP::bdlt::operator!=

Return true if the two datetimes do not have the same value.

BloombergLP::bdlt::operator==

Return true if the two datetimes have the same value.

BloombergLP::bdlt::operator‐

Return the interval between two datetimes.

Non-Member Functions

Name

Description

operator+

Return the sum of a time interval and a datetime.

operator+

Return the sum of a datetime and a time interval.

operator+

Return the sum of a datetime interval and a datetime.

operator+

Return the sum of a datetime and a datetime interval.

operator‐

Return the difference of a datetime and a time interval.

operator‐

Return the difference of a datetime and a datetime interval.

operator<

Return true if datetime lhs is less than timetable transition rhs.

Created with MrDocs