gpt4 book ai didi

c++ - 将 COleDateTime 转换为刻度或整数表示

转载 作者:搜寻专家 更新时间:2023-10-31 01:13:02 24 4
gpt4 key购买 nike

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

最佳答案

我认为最简单的方法是通过 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 );

关于c++ - 将 COleDateTime 转换为刻度或整数表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13096225/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com