Added TimeStamp option to Time measures

This commit is contained in:
Brian Ferguson 2012-08-29 09:59:36 -06:00
parent 1ba617d829
commit de1cfb8504
2 changed files with 20 additions and 8 deletions

View File

@ -46,7 +46,8 @@ int GetYearDay(int year, int month, int day)
*/
CMeasureTime::CMeasureTime(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name),
m_DeltaTime(),
m_Time()
m_Time(),
m_TimeStamp(-1)
{
/* Set time zone from TZ environment variable. If TZ is not set,
* the operating system is queried to obtain the default value
@ -89,15 +90,22 @@ void CMeasureTime::TimeToString(WCHAR* buf, size_t bufLen, const WCHAR* format,
void CMeasureTime::FillCurrentTime()
{
FILETIME ftUTCTime;
GetSystemTimeAsFileTime(&ftUTCTime);
if (m_TimeStamp < 0.0)
{
FILETIME ftUTCTime;
GetSystemTimeAsFileTime(&ftUTCTime);
// Modify the ltime to match the current timezone
// This way we can use the value also for the clock
m_Time.HighPart = ftUTCTime.dwHighDateTime;
m_Time.LowPart = ftUTCTime.dwLowDateTime;
// Modify the ltime to match the current timezone
// This way we can use the value also for the clock
m_Time.HighPart = ftUTCTime.dwHighDateTime;
m_Time.LowPart = ftUTCTime.dwLowDateTime;
m_Time.QuadPart += m_DeltaTime.QuadPart;
m_Time.QuadPart += m_DeltaTime.QuadPart;
}
else
{
m_Time.QuadPart = (LONGLONG)(m_TimeStamp * 10000000);
}
}
/*
@ -221,6 +229,8 @@ void CMeasureTime::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_Format = parser.ReadString(section, L"Format", L"");
m_TimeStamp = parser.ReadFloat(section, L"TimeStamp", -1);
const WCHAR* timezone = parser.ReadString(section, L"TimeZone", L"local").c_str();
if (_wcsicmp(L"local", timezone) == 0)
{

View File

@ -42,6 +42,8 @@ private:
std::wstring m_Format;
LARGE_INTEGER m_DeltaTime;
LARGE_INTEGER m_Time;
double m_TimeStamp;
};
#endif