summaryrefslogtreecommitdiff
path: root/lib/common/BoxTime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/BoxTime.cpp')
-rw-r--r--lib/common/BoxTime.cpp14
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;