diff options
author | Chris Wilson <chris+github@qwirx.com> | 2009-03-29 14:08:12 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2009-03-29 14:08:12 +0000 |
commit | 077b00d6c5c967e1403a39fa5bd8843c039199eb (patch) | |
tree | 95942e8aaec11650451e00a2ee31582bd5ca32b4 /lib/common/BoxTime.cpp | |
parent | ef3d1642c083a9c69eb48c6ab8ecc9be43dfbcfc (diff) |
Add date to file logger, as requested by Kenny Millington.
Diffstat (limited to 'lib/common/BoxTime.cpp')
-rw-r--r-- | lib/common/BoxTime.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/common/BoxTime.cpp b/lib/common/BoxTime.cpp index 0d099db5..d05c0a6c 100644 --- a/lib/common/BoxTime.cpp +++ b/lib/common/BoxTime.cpp @@ -53,7 +53,7 @@ box_time_t GetCurrentBoxTime() return SecondsToBoxTime(time(0)); } -std::string FormatTime(box_time_t time, bool showMicros) +std::string FormatTime(box_time_t time, bool includeDate, bool showMicros) { std::ostringstream buf; @@ -68,8 +68,16 @@ std::string FormatTime(box_time_t time, bool showMicros) if (localtime_r(&seconds, &tm_now) != NULL) #endif { - buf << std::setfill('0') << - std::setw(2) << tm_ptr->tm_hour << ":" << + buf << std::setfill('0'); + + if (includeDate) + { + buf << std::setw(4) << (tm_ptr->tm_year + 1900) << "-" << + std::setw(2) << (tm_ptr->tm_mon + 1) << "-" << + std::setw(2) << (tm_ptr->tm_mday) << " "; + } + + buf << std::setw(2) << tm_ptr->tm_hour << ":" << std::setw(2) << tm_ptr->tm_min << ":" << std::setw(2) << tm_ptr->tm_sec; |