From 29eda094a73c9df71bf78e29e0e496a82161e283 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 7 Aug 2020 13:17:52 +0200 Subject: [PATCH] show drive stats human readable --- include/reHDD.h | 2 ++ src/drive.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/reHDD.h b/include/reHDD.h index 0fdf6fc..df32002 100644 --- a/include/reHDD.h +++ b/include/reHDD.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include using namespace std; diff --git a/src/drive.cpp b/src/drive.cpp index 67b28f8..cb30cca 100644 --- a/src/drive.cpp +++ b/src/drive.cpp @@ -67,12 +67,18 @@ string Drive::sCapacityToText() string Drive::sPowerOnHoursToText(){ + double dYears = 0U; + uint32_t u32Hours = getPowerOnHours(); + stringstream stream; - //TODO show in human readable format - - return to_string(getPowerOnHours()); + dYears = (double) ((double)u32Hours/(double)8760U); + + stream << fixed << setprecision(2) << dYears; + string sRet = to_string(getPowerOnHours()) + " hours or " + stream.str() + " years"; + return sRet; } + string Drive::sPowerCyclesToText(){ return to_string(getPowerCycles()); }