aboutsummaryrefslogtreecommitdiff
path: root/libbutl/timestamp.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-06-08 23:23:07 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-06-14 17:54:26 +0300
commitcf703f3e302312e1602fe46dc2c1e32dee786e6b (patch)
treef5e5fa80faad6f4f87765e3a7fd51c5d65f753b9 /libbutl/timestamp.hxx
parent0f4d52b4e907fcefabf8fd05c9d122da48664b4b (diff)
Add to_stream(duration) and to_string(duration)
Diffstat (limited to 'libbutl/timestamp.hxx')
-rw-r--r--libbutl/timestamp.hxx18
1 files changed, 16 insertions, 2 deletions
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.
//