|
#include "StdAfx.h"
#include "TimeParser.h"
TimeParser::TimeParser( const DWORD dwStartTime_i,
const SYSTEMTIME& stStartupTime_i )
{
m_dwStartTime = dwStartTime_i;
m_SystemStartTime = stStartupTime_i;
m_stStartTime = stStartupTime_i;
}
TimeParser::~TimeParser(void)
{
}
/*
This function receives a TickCount( DWORD ) and provides SYSTEMTIME as output.
The starttime( SYSTEMTIME instance) and its tickcount is used to convert
current tickcount to SYSTEMTIME.
*/
SYSTEMTIME TimeParser::ConvertTickCountToSysTime( const DWORD dwTickCount_i )
{
DWORD dwDiff = dwTickCount_i - m_dwStartTime; // Ms after startup Time.
// CTimeSpan timeSpanObj( dwDiff / 1000 );
// CTime timeInSec = m_SystemStartTime + timeSpanObj;
SYSTEMTIME stToAdd = m_stStartTime;
stToAdd.wMilliseconds += dwDiff;
long lSeconds = 0;
if( stToAdd.wMilliseconds > 1000 )
{
lSeconds = ( stToAdd.wMilliseconds / 1000 );
}
// LONG lDays, int nHours, int nMins, int nSecs
CTimeSpan timeSpan( 0, 0, 0, lSeconds );
int nMsOutput = stToAdd.wMilliseconds % 1000;
// Reset Millisecond to 0, avoid calculation from CTime class.
stToAdd.wMilliseconds = 0;
CTime stToAddObj = stToAdd;
stToAddObj = stToAddObj + timeSpan;
stToAddObj.GetAsSystemTime( stToAdd );
stToAdd.wMilliseconds = nMsOutput;
return stToAdd;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.