COleDateTime::operator +, -

COleDateTime operator +( const COleDateTimeSpan& dateSpan ) const;

COleDateTime operator -( const COleDateTimeSpan& dateSpan ) const;

COleDateTimeSpan operator -( const COleDateTime& date ) const;

Remarks

COleDateTime objects represent absolute times. COleDateTimeSpan objects represent relative times. The first two operators allow you to add and subtract a COleDateTimeSpan value from a COleDateTime value. The third operator allows you to subtract one COleDateTime value from another to yield a COleDateTimeSpan value.

If either of the operands is null, the status of the resulting COleDateTime value is null.

If the resulting COleDateTime value falls outside the bounds of acceptable values, the status of that COleDateTime value is invalid.

If either of the operands is invalid and the other is not null, the status of the resulting COleDateTime value is invalid.

For more information on the valid, invalid, and null status values, see the m_status member variable.

For more information about the bounds for COleDateTime values, see the article Date and Time: Automation Support in Visual C++ Programmer’s Guide.

Example

COleDateTime t1( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
COleDateTime t2( 1999, 3, 20, 22, 15, 0 ); // 10:15PM March 20, 1999

// Subtract 2 COleDateTimes
COleDateTimeSpan ts = t2 - t1;

// one day is 24 * 60 * 60 == 86400 seconds
ASSERT( ts.GetTotalSeconds() == 86400L );

// Add a COleDateTimeSpan to a COleDateTime.
ASSERT( ( t1 + ts ) == t2 );

// Subtract a COleDateTimeSpan from a COleDateTime.
ASSERT( ( t2 - ts ) == t1 );

COleDateTime OverviewClass MembersHierarchy Chart

See Also   COleDateTime::operator +=, -=, COleDateTime::GetStatus, COleDateTimeSpan