Permalink
Browse files

Added TimeStamp option to Time measures

  • Loading branch information...
1 parent 1ba617d commit de1cfb85040731a1e0e2ca4d989b36daba58324c @brianferguson brianferguson committed Aug 29, 2012
Showing with 20 additions and 8 deletions.
  1. +18 −8 Library/MeasureTime.cpp
  2. +2 −0 Library/MeasureTime.h
View
@@ -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
@@ -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.