From 784f2c18990b71090f267db31a328b81b231b0a6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Jun 2017 20:35:56 +0300 Subject: Fix printing duration --- libbutl/timestamp.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libbutl/timestamp.cxx') diff --git a/libbutl/timestamp.cxx b/libbutl/timestamp.cxx index aae4622..eb4b5ce 100644 --- a/libbutl/timestamp.cxx +++ b/libbutl/timestamp.cxx @@ -244,7 +244,7 @@ namespace butl time_t t (system_clock::to_time_t (ts)); const char* fmt (nullptr); - const char* unt ("nanoseconds"); + const char* unt; if (t >= 365 * 24 * 60 * 60) { fmt = "%Y-%m-%d %H:%M:%S"; @@ -275,6 +275,8 @@ namespace butl fmt = "%S"; unt = "seconds"; } + else + unt = ns ? "nanoseconds" : "seconds"; if (fmt != nullptr) { @@ -317,8 +319,6 @@ namespace butl } else os << nsec.count (); - - os << ' ' << unt; } else if (fmt == nullptr) os << '0'; @@ -326,6 +326,7 @@ namespace butl else if (fmt == nullptr) os << '0'; + os << ' ' << unt; return os; } -- cgit v1.1