怎么求一个时间的之后一天?
例如:一个时间变量time1,怎么用表达式表示它之后一天?
类似 VB中DATEADD函数。

解决方案 »

  1.   

    CTime time1 ;
    ..
    CTimeSpan timespan(1,0,0,0);
    time1 += timespan;
    strtemp=time1.Format("%Y年%m月%d日");
      

  2.   

    // example for CTimeSpan::CTimeSpan
    CTimeSpan ts1;  // Uninitialized time value
    CTimeSpan ts2a( ts1 ); // Copy constructor
    CTimeSpan ts2b = ts1; // Copy constructor again
    CTimeSpan ts3( 100 ); // 100 seconds
    CTimeSpan ts4( 0, 1, 5, 12 );    // 1 hour, 5 minutes, and 12 seconds
      

  3.   

    MSDN:
        Debug version of the Microsoft Foundation Class Library asserts if one or more of the time-day components is out of range. It is your responsibility to validate the arguments prior to calling.
    CTimeSpan ts1;  // Uninitialized time value
    CTimeSpan ts2a( ts1 ); // Copy constructor
    CTimeSpan ts2b = ts1; // Copy constructor again
    CTimeSpan ts3( 100 ); // 100 seconds
    CTimeSpan ts4( 0, 1, 5, 12 );    // 1 hour, 5 minutes, and 12 seconds