From cf703f3e302312e1602fe46dc2c1e32dee786e6b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Jun 2017 23:23:07 +0300 Subject: Add to_stream(duration) and to_string(duration) --- libbutl/timestamp.hxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'libbutl/timestamp.hxx') diff --git a/libbutl/timestamp.hxx b/libbutl/timestamp.hxx index 9fb0f59..8a5c71a 100644 --- a/libbutl/timestamp.hxx +++ b/libbutl/timestamp.hxx @@ -88,7 +88,7 @@ namespace butl bool special, bool local); - // Same as above, but provide the result as string. Note that it is + // Same as above, but provide the result as a string. Note that it is // implemented via to_stream() and std::ostringstream. // LIBBUTL_EXPORT std::string @@ -103,8 +103,22 @@ namespace butl return to_stream (os, ts, "%Y-%m-%d %H:%M:%S%[.N]", true, true); } + // Print human-readable representation of the duration. + // LIBBUTL_EXPORT std::ostream& - operator<< (std::ostream&, const duration&); + to_stream (std::ostream&, const duration&, bool nanoseconds); + + // Same as above, but provide the result as a string. Note that it is + // implemented via to_stream() and std::ostringstream. + // + LIBBUTL_EXPORT std::string + to_string (const duration&, bool nanoseconds); + + inline std::ostream& + operator<< (std::ostream& os, const duration& d) + { + return to_stream (os, d, true); + } // Parse human-readable representation of the timestamp. // -- cgit v1.1