diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-07-24 17:12:30 +0200 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-07-25 16:25:42 +0200 |
commit | e0fd7becaa93367c9d576084449b5404e16c762b (patch) | |
tree | b1f5fc7c6b13d26f574fdfca30041b063ab368ce /src/lib/util/boost_time_utils.cc | |
parent | Apply suggestion to src/lib/util/boost_time_utils.cc (diff) | |
download | kea-e0fd7becaa93367c9d576084449b5404e16c762b.tar.xz kea-e0fd7becaa93367c9d576084449b5404e16c762b.zip |
[#175,!414] Addressed more review comments
src/lib/util/boost_time_utils.*
renamed DEFAULT_FRAC_SECS to MAX_FSECS_PRECISION
added commentary and fixed indentation
src/lib/util/tests/boost_time_utils_unittest.cc
added commentary
Diffstat (limited to 'src/lib/util/boost_time_utils.cc')
-rw-r--r-- | src/lib/util/boost_time_utils.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/util/boost_time_utils.cc b/src/lib/util/boost_time_utils.cc index eee1a55f1b..3719f727f4 100644 --- a/src/lib/util/boost_time_utils.cc +++ b/src/lib/util/boost_time_utils.cc @@ -28,9 +28,11 @@ isc::util::durationToText(boost::posix_time::time_duration dur, size_t fsecs_pre << ":" << std::setw(2) << std::setfill('0') << dur.minutes() << ":" << std::setw(2) << std::setfill('0') << dur.seconds(); + // 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) { size_t fsecs = dur.fractional_seconds(); - size_t width = DEFAULT_FRAC_SECS; + size_t width = MAX_FSECS_PRECISION; if (fsecs_precision < width) { for (auto i = 0; i < width - fsecs_precision; ++i) { fsecs /= 10; @@ -39,9 +41,9 @@ isc::util::durationToText(boost::posix_time::time_duration dur, size_t fsecs_pre width = fsecs_precision; } - s << "." << std::setw(width) - << std::setfill('0') - << fsecs; + s << "." << std::setw(width) + << std::setfill('0') + << fsecs; } return (s.str()); |