aboutsummaryrefslogtreecommitdiffstats
path: root/src/Stats.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-08-29 23:22:46 +0200
committerMax Kellermann <max@duempel.org>2014-08-29 23:25:03 +0200
commit58352ea69d3e40bd3c91eacc7bbd48f58d5f2c8a (patch)
tree98b0f981114a98177e7cb805cefa6c1c335dd6fd /src/Stats.cxx
parentde64b35359dff6f052aee4b38042c0d91ae5aefb (diff)
downloadmpd-58352ea69d3e40bd3c91eacc7bbd48f58d5f2c8a.tar.gz
mpd-58352ea69d3e40bd3c91eacc7bbd48f58d5f2c8a.tar.xz
mpd-58352ea69d3e40bd3c91eacc7bbd48f58d5f2c8a.zip
db/Stats: use std::chrono::duration for the total duration
Use milliseconds precision to reduce rounding errors.
Diffstat (limited to 'src/Stats.cxx')
-rw-r--r--src/Stats.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Stats.cxx b/src/Stats.cxx
index 8fc626ecb..39d371ace 100644
--- a/src/Stats.cxx
+++ b/src/Stats.cxx
@@ -99,15 +99,18 @@ db_stats_print(Client &client, const Database &db)
if (!stats_update(db))
return;
+ unsigned total_duration_s =
+ std::chrono::duration_cast<std::chrono::seconds>(stats.total_duration).count();
+
client_printf(client,
"artists: %u\n"
"albums: %u\n"
"songs: %u\n"
- "db_playtime: %lu\n",
+ "db_playtime: %u\n",
stats.artist_count,
stats.album_count,
stats.song_count,
- stats.total_duration);
+ total_duration_s);
const time_t update_stamp = db.GetUpdateStamp();
if (update_stamp > 0)