/// @file Utils.cc /// @brief Implementation of the utility classes. #include "Utils.h" namespace Utils { // MyWid - number formatting utility implementation MyWid::MyWid(const double num, const unsigned width, const unsigned precision) { if (precision > 0) { oss_ << std::setfill(' ') << std::showpoint << std::fixed << std::setw(width - 1) << std::setprecision(precision) << num; } else { oss_ << std::fixed << std::setw(width - 1) << std::setprecision(precision) << num; } } MyHex::MyHex(const UChar_t num, const unsigned width) { oss_ << "0x" << std::fixed << std::setw(width) << std::setfill('0') << Int_t(num); } // // TimeHandler constructor // TimeHandler::TimeHandler(double time) { SetTime(time); } void TimeHandler::SetTime(double time) { m_time_s = time; m_time = time; //cout << "DEBUG TMP: " << Utils::MyWid(time,30,8) << endl; string ts = static_cast(ctime(&m_time)); string m_day = ts.substr( 0,3); string m_mon = ts.substr( 4,3); int m_dat = atoi(ts.substr( 8,2).c_str()); int m_hou = atoi(ts.substr(11,2).c_str()); int m_min = atoi(ts.substr(14,2).c_str()); int m_sec = atoi(ts.substr(17,2).c_str()); string m_yea = ts.substr(20,4); double secfrac = m_time_s - double(int(m_time_s)); m_px_time.str(""); m_px_time << m_day << " " << m_mon << " " << setfill('0') << setw(2) << m_dat << " " << setfill('0') << setw(2) << m_hou << ":" << setfill('0') << setw(2) << m_min << ":" << showpoint << fixed << setfill('0') << setw(9) << setprecision(6) << double(m_sec) + secfrac << " " << m_yea; }//end of TimeHandler constructor. }//end of Utils namespace.