编写c++程序来计算任何两个日期之间的天数和
发布网友
发布时间:2022-07-28 14:46
我来回答
共1个回答
热心网友
时间:2023-11-08 12:46
编译平台:Visual Studio 2005 Visual C++
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 );
ASSERT( ts.GetTotalDays() == 1)
// Add a COleDateTimeSpan to a COleDateTime.
ASSERT( ( t1 + ts ) == t2 );
// Subtract a COleDateTimeSpan from a COleDateTime.
ASSERT( ( t2 - ts ) == t1 );