我正在尝试在 C# 中实现CTime::GetTime()
方法的行为。
这是我的控制台应用程序的代码片段(用 C++/CLI 编写):
int main(array<System::String ^> ^args)
{
int epochYear = 1970;
int epochMonth = 1;
int epochDay = 1;
DateTime managedEpochDate = DateTime(epochYear, epochMonth, epochDay);
int year = 2013;
int month = 2;
int day = 13;
int hour = 9;
int minutes = 49;
int seconds = 46;
// DateTime/CTime -> Numeric Time (__time64_t)
DateTime managedDateTime = DateTime(year, month, day, hour, minutes, seconds);
CTime nativeDateTime = CTime(year, month, day, hour, minutes, seconds);
DWORD nativeTimeToSerialize = nativeDateTime.GetTime();
UInt32 managedTimeToSerialize = (managedDateTime - managedEpochDate)
.TotalSeconds;
}
最后,我有以下不同的值:
- nativeTimeToSerialize = 1360745386
- managedTimeToSerialize = 1360748986
谁能帮我理解这种差异的原因?