Changeset 8232 for code/trunk/src/libraries/util/StringUtils.cc
- Timestamp:
- Apr 11, 2011, 7:37:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/StringUtils.cc
r7401 r8232 35 35 36 36 #include <cctype> 37 #include <ctime> 37 38 #include <boost/scoped_array.hpp> 38 39 #include "Convert.h" … … 516 517 return matrix[(rows-1)*cols + cols-1]; 517 518 } 519 520 /** 521 @brief 522 Get a timestamp for the curent time instant. 523 @return 524 Returns a string with the timestamp. 525 */ 526 std::string getTimestamp(void) 527 { 528 struct tm *pTime; 529 time_t ctTime; std::time(&ctTime); 530 pTime = std::localtime( &ctTime ); 531 std::ostringstream oss; 532 oss << std::setw(2) << std::setfill('0') << (pTime->tm_mon + 1) 533 << std::setw(2) << std::setfill('0') << pTime->tm_mday 534 << std::setw(2) << std::setfill('0') << (pTime->tm_year + 1900) 535 << "_" << std::setw(2) << std::setfill('0') << pTime->tm_hour 536 << std::setw(2) << std::setfill('0') << pTime->tm_min 537 << std::setw(2) << std::setfill('0') << pTime->tm_sec; 538 return oss.str(); 539 } 518 540 }
Note: See TracChangeset
for help on using the changeset viewer.