36  const std::size_t secondsPerMinute = 60;
 
   37  const std::size_t secondsPerHour = 60 * secondsPerMinute;
 
   38  const std::size_t secondsPerDay = 24 * secondsPerHour;
 
   41  std::size_t       iSeconds = 
static_cast<std::size_t
>(totalSeconds);
 
   42  const std::size_t days = iSeconds / secondsPerDay;
 
   44  iSeconds %= secondsPerDay;
 
   45  const std::size_t hours = iSeconds / secondsPerHour;
 
   47  iSeconds %= secondsPerHour;
 
   48  const std::size_t minutes = iSeconds / secondsPerMinute;
 
   52  const double dSeconds = std::fmod(totalSeconds, 60.0);
 
   56  std::ostringstream make_string;
 
   59    make_string << days << 
"d";
 
   62  if (hours != 0 || nonzero)
 
   64    make_string << hours << 
"h";
 
   67  if (minutes != 0 || nonzero)
 
   69    make_string << minutes << 
"m";
 
   71  make_string << std::showpoint << std::fixed << std::setprecision(precision);
 
   72  make_string << dSeconds << 
"s";
 
   75  return make_string.str();
 
 
   85  const std::time_t rawtime{ std::time(
nullptr) };
 
   89  const std::tm * 
const localTimePtr{ std::localtime(&rawtime) };
 
   91  if (localTimePtr == 
nullptr)
 
   93    assert(!
"std::localtime should not return null!");
 
   99  const std::tm localTimeValue(*localTimePtr);
 
  101  constexpr std::size_t maxNumberOfChars{ 32 };
 
  102  char                  timeAsString[maxNumberOfChars]{};
 
  103  static_assert(maxNumberOfChars > 
sizeof(
"Thu Aug 23 14:55:02 2001"),
 
  104                "timeAsString should be large enough to hold a typical example date and time");
 
  106  if (std::strftime(timeAsString, maxNumberOfChars, 
"%c", &localTimeValue) == 0)
 
  108    assert(!
"std::strftime has failed!");