Skip to content

Commit

Permalink
Added TimeStamp option to Time measures
Browse files Browse the repository at this point in the history
  • Loading branch information
brianferguson committed Aug 29, 2012
1 parent 1ba617d commit de1cfb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Library/MeasureTime.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

/*
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions Library/MeasureTime.h
Expand Up @@ -42,6 +42,8 @@ class CMeasureTime : public CMeasure
std::wstring m_Format;
LARGE_INTEGER m_DeltaTime;
LARGE_INTEGER m_Time;

double m_TimeStamp;
};

#endif

0 comments on commit de1cfb8

Please sign in to comment.