]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1174] Added duration_cast in printing
authorFrancis Dupont <fdupont@isc.org>
Wed, 1 Apr 2020 09:21:03 +0000 (11:21 +0200)
committerTomek Mrugalski <tomek@isc.org>
Tue, 14 Jul 2020 13:37:51 +0000 (15:37 +0200)
src/lib/util/chrono_time_utils.cc

index f35139755188143782ab729381491cc85efede0e..4905c8b2e80abab23e689d2f4a51348a39468c52 100644 (file)
@@ -28,7 +28,8 @@ isc::util::clockToText(system_clock::time_point t, size_t fsecs_precision) {
     // If the requested precision is less than the maximum native precision
     // we will divide the fractional seconds value by 10^(max - requested)
     if (fsecs_precision) {
-        microseconds frac = t - system_clock::from_time_t(tt);
+        system_clock::duration dur = t - system_clock::from_time_t(tt);
+        microseconds frac = duration_cast<microseconds>(dur);
         auto fsecs = frac.count();
         size_t width = MAX_FSECS_PRECISION;
         if (fsecs_precision < width) {
@@ -63,7 +64,8 @@ isc::util::durationToText(system_clock::duration dur, size_t fsecs_precision) {
     // If the requested precision is less than the maximum native precision
     // we will divide the fractional seconds value by 10^(max - requested)
     if (fsecs_precision) {
-        microseconds frac = dur - unfrac;
+        microseconds frac = duration_cast<microseconds>(dur);
+        frac -= duration_cast<microseconds>(unfrac);
         auto fsecs = frac.count();
         size_t width = MAX_FSECS_PRECISION;
         if (fsecs_precision < width) {