* \brief Time in seconds to printed string format * * \param[in] time_secs Time since epoch in seconds * \param[in] time_us Microseconds to add to timestamp * \param[out] ts_str Reference to storage of string value * */
| 637 | * |
| 638 | */ |
| 639 | void getTimestamp(uint32_t time_secs, uint32_t time_us, std::string &ts_str){ |
| 640 | char buf[48]; |
| 641 | timeval tv; |
| 642 | std::time_t secs; |
| 643 | uint32_t us; |
| 644 | tm *p_tm; |
| 645 | |
| 646 | if (time_secs <= 1000) { |
| 647 | gettimeofday(&tv, NULL); |
| 648 | secs = tv.tv_sec; |
| 649 | us = tv.tv_usec; |
| 650 | |
| 651 | } else { |
| 652 | secs = time_secs; |
| 653 | us = time_us; |
| 654 | } |
| 655 | |
| 656 | p_tm = std::gmtime(&secs); |
| 657 | std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", p_tm); |
| 658 | ts_str = buf; |
| 659 | |
| 660 | sprintf(buf, ".%06u", us); |
| 661 | ts_str.append(buf); |
| 662 | } |
| 663 | |
| 664 | protected: |
| 665 |
nothing calls this directly
no outgoing calls
no test coverage detected