
#if !defined(_HARKLIB_STRDURLOG_H_INCLUDED_)
#define _HARKLIB_STRDURLOG_H_INCLUDED_


#include <string>
#include <chrono>
#include <sstream>
#include <iostream>
#include <iomanip>

namespace hark
{

static std::string DurationLog(const std::chrono::nanoseconds dt){
    std::chrono::microseconds dus = std::chrono::duration_cast<std::chrono::microseconds>(dt);
    std::chrono::seconds dsec = std::chrono::duration_cast<std::chrono::seconds>(dus);
    std::chrono::minutes dmin = std::chrono::duration_cast<std::chrono::minutes>(dus);
    std::chrono::hours dhour = std::chrono::duration_cast<std::chrono::hours>(dus);

    std::stringstream ss;

    ss        << std::setfill('0') << std::setw(2) << (int) dhour.count()
       << ":" << std::setfill('0') << std::setw(2) << (int) dmin.count() - dhour.count() * 60
       << ":" << std::setfill('0') << std::setw(2) << (int) dsec.count() - dmin.count() * 60
       << "." << std::setfill('0') << std::setw(6) << (unsigned int) dus.count() - dsec.count() * 1e6;

    return ss.str();
}

} // end of namespace

#endif /* !defined(_HARKLIB_STRDURLOG_H_INCLUDED_) */

/* end of file */
