Domanda

noob to C++. I have a CTime (actually it's a CTimeEx) object. The value of the time value is:

CExTime now = now.GetSystemTime();

I am receiving an int, such as 60, to add to that time; this means that if I have 12:01:30 , then I'd want 12:02:30.

How can I add the int to the CTime? Would this work?

currBERecored.m_BeUpdateTime = now + secondsFromFile;
È stato utile?

Soluzione

You can add via the + operator a CTimeSpan to a CTime object. The CTimeSpan is the correct class to represent a time interval, you can construct a CTimeSpan of a certain number of seconds by using this constructor:

CTimeSpan(
   __time64_t time 
) throw( ); 

in which time is the desired amount of seconds.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top