コード例 #1
0
ファイル: Clock.cpp プロジェクト: obhi-d/nextar
/*
 ./ Tick
 */
uint32 Clock::Tick() {
	NEX_ASSERT(!stopped);
	uint32 curTime = GetMilliSecs();
	elapsedMilliSecs = curTime - lastTick;
	lastTick = curTime;
	return elapsedMilliSecs;
}
コード例 #2
0
///////////////////////////////////////////////////////////////////////////
//	Name:	SetMilliSecs
//
//	Description:
//	Set the number of milliseconds associated with the current DATE value
//
//	Declaration:
//	void CMyDateTime::SetMilliSecs(DATE *pdDateTime, const int nMilliSecs)
//
//	Input:	pdDateTime	- DATE to set the milliseconds on
//			nMilliSecs	- number of milliseconds to set on the COleDateTime
//			
//	Output:	pdDateTime	- DATE with the proper number of milliseconds
//
//	Return:	none
//	
//  date    /	author	revision
//  -----------------	--------
//	01-Jun-2002	SFK		Adapted from routine from ToM
//////////////////////////////////////////////////////////////////
void CMyDateTime::SetMilliSecs(DATE *pdDateTime, const int nMilliSecs)
{
        int nCurrentMilliSecs = GetMilliSecs(*pdDateTime);		// get existing number of ms
        double dFracDays = (double)(nMilliSecs - nCurrentMilliSecs) / 1000.0 / 86400.0;

        *pdDateTime += dFracDays;
        return;
}
コード例 #3
0
///////////////////////////////////////////////////////////////////////////
//	Name:	DATETimestampToDateTimeStrs
//
//	Description:
//	Converts a DATE timestamp to date and time strings.  The date format is specified to be either
//	the native format specified by the OS or IAEA format which is yy.mm.dd hh:mm:ss.  If the time format
//	requests milliseconds the time is expressed as hh:mm:ss.xxx where xxx is the number of milliseconds.
//
//	Declaration:
//	void CMyDateTime::DATETimestampToDateTimeStrs(const DATE dTimestamp, char *pDateStr, char *pTimeStr, const int iDateFormat, const int iTimeFormat)
//
//	Input:	dTimestamp	- timestamp in DATE format to be converted
//			iDateFormat - format supported: OS or GEN_DTF_IAEA or DTF_4DIGIT_YEAR.  Default is GEN_DTF_IAEA.
//			iTimeFormat - either hh:mm:ss (GEN_DTF_HMS) or hh:mm:ss.mmm (GEN_DTF_HMSM).  Default is GEN_DTF_HMS. 
//			
//	Output:	pDateStr	- string containing date in specified format (user must allocate storage)
//			pTimeStr	- string continaing time in specified format (user must allocate storage)
//
//	Return:	none
//	
//  date    /	author	revision
//  -----------------	--------
//	01-Jun-2002	SFK		Created
//	05-May-2003	SFK		Added another format defintion to always produce 4-digit years.  Used when producing files for IR.
//////////////////////////////////////////////////////////////////
void CMyDateTime::DATETimestampToDateTimeStrs(
	const DATE dTimestamp, 
	char *pDateStr, 
	char *pTimeStr, 
	const int iDateFormat, 
	const int iTimeFormat)
{
	//gen_seconds_to_date_time_str(pszFirstDate, szTime, &ulFirstDbDay, GEN_DTF_IAEA);
	COleDateTime oleTimestamp;
	DATE dTempTimestamp;
	CString strDate, strTime, strTemp;
	
	// get rid of any ms before using the conversions and format them at the end
	// appears the COle stuff rounds it up.
	int iMilliSecs = GetMilliSecs(dTimestamp);
	dTempTimestamp = dTimestamp - (double)((iMilliSecs/1000.0)/86400.0);
	oleTimestamp.m_dt = dTempTimestamp;
	
	if (iDateFormat == 0) {		// default to the format selected by the OS
		strDate = oleTimestamp.Format(VAR_DATEVALUEONLY);
	}
	else if (iDateFormat == GEN_DTF_IAEA) {	// use yy.mm.dd
		strDate = oleTimestamp.Format("%y.%m.%d");
	}
	else if (iDateFormat == DTF_4DIGIT_YEAR) {	// use yyyy.mm.dd
		strDate = oleTimestamp.Format("%Y.%m.%d");
	}

	// do the time stuff
	// sfk 7/14/2003 strTime = oleTimestamp.Format(VAR_TIMEVALUEONLY);
	strTime = oleTimestamp.Format("%H:%M:%S");
	int iDum = strTime.GetLength();
	if (strTime.GetLength() == 0) strTime = "00:00:00";
	if (iTimeFormat == GEN_DTF_HMSM) {
		strTemp.Format(".%03d", iMilliSecs);
		strTime += strTemp;		// append ms to timestring
	}

	strncpy(pDateStr, strDate.GetBuffer(MAX_DT_LEN+1), MAX_DT_LEN+1);
	strDate.ReleaseBuffer(); //KDM5
	strncpy(pTimeStr, strTime.GetBuffer(MAX_DT_LEN+1), MAX_DT_LEN+1);
	strTime.ReleaseBuffer(); //KDM5


}
コード例 #4
0
ファイル: Clock.cpp プロジェクト: obhi-d/nextar
void Clock::ResetClock() {
	Reset();
	lastTick = GetMilliSecs();
	elapsedMilliSecs = 0;
	stopped = false;
}