Commit 2b51445a authored by Cédric Traizet's avatar Cédric Traizet
Browse files

REFAC: remove trailing zeros and add UTC time identifier (Z) when printing...

REFAC: remove trailing zeros and add UTC time identifier (Z) when printing dates with a decimal second part
parent a3c8415c
......@@ -102,7 +102,7 @@ public:
TimePoint(): m_Time(InternalTimePointType::min()) {}
TimePoint(InternalTimePointType const& t): m_Time(t) {}
std::ostream & Display(std::ostream & os, const std::string & format = details::timePointFormat) const;
std::ostream & Display(std::ostream & os) const;
std::istream & Read (std::istream & is, const std::string & format = details::timePointFormat);
template <typename U, typename V> static U diff(V const& lhs, V const& rhs)
......@@ -48,9 +48,16 @@ TimePoint ReadFormattedDate(const std::string & dateStr, const std::string & for
return tp;
std::ostream & TimePoint::Display(std::ostream & os, const std::string& format) const
std::ostream & TimePoint::Display(std::ostream & os) const
date::to_stream(os, format.c_str(), m_Time);
auto dateStr = date::format( "%Y-%m-%dT%H:%M:%S", m_Time);
// date::format %S returns the number of seconds with a fixed size format (ns precision)
// Remove the trailing zeros in the output.
dateStr.erase(dateStr.find_last_not_of('0') + 1, std::string::npos);
// Add the UTC time identifier
os << dateStr << "Z";
return os;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment