Allow conversion of TimeSpan to string with total seconds

This commit is contained in:
Martchus 2017-11-27 10:24:26 +01:00
parent 424a0bfb6f
commit 3051675bbe
2 changed files with 8 additions and 1 deletions

View File

@ -157,6 +157,12 @@ void TimeSpan::toString(string &result, TimeSpanOutputFormat format, bool fullSe
}
}
break;
case TimeSpanOutputFormat::TotalSeconds:
if (fullSeconds) {
s << setprecision(0);
}
s << positive.totalSeconds();
break;
}
result = s.str();
}

View File

@ -21,7 +21,8 @@ class DateTime;
*/
enum class TimeSpanOutputFormat {
Normal, /**< the normal form of specifing a time interval: hh:mm:ss */
WithMeasures /**< measures are used, eg.: 34 d 5 h 10 min 7 s 31 ms */
WithMeasures, /**< measures are used, eg.: 34 d 5 h 10 min 7 s 31 ms */
TotalSeconds, /**< total seconds (as returned by totalSeconds()), eg. 2304.342 */
};
class CPP_UTILITIES_EXPORT TimeSpan {