2

如何将 COleDateTime 转换为可以轻松转换回来的某种整数表示形式。

4

1 回答 1

5

我认为最简单的方法COleDateTimeSpan如下:

// Create an epoch
static COleDateTime epoch( 2000, 1, 1, 0, 0, 0 );

// Convert to integer
COleDateTime someTime;    // initialize it from somewhere
__int64 nOleDateTimeAsInt = static_cast<__int64>( (someTime - epoch).totalSeconds() );

// Create from integer
COleDateTimeSpan span( nOleDateTimeAsInt / SecondsInDay,
    (nOleDateTime % SecondsInDay) / SecondsInHour,
    (nOleDateTime % SecondsInHour) / SecondsInMinute,
    (nOleDateTime % SecondsInMinute) );
COleDateTime someTime( epoch + span );
于 2012-10-27T01:39:22.773 回答