28 #include "itkObject.h" 29 #include "itkDataObject.h" 30 #include <itksys/SystemTools.hxx> 31 #include <itksys/SystemInformation.hxx> 32 #include "itkTimeProbe.h" 54 const std::size_t secondsPerMinute = 60;
55 const std::size_t secondsPerHour = 60 * secondsPerMinute;
56 const std::size_t secondsPerDay = 24 * secondsPerHour;
59 std::size_t iSeconds =
static_cast<std::size_t
>( totalSeconds );
60 const std::size_t days = iSeconds / secondsPerDay;
62 iSeconds %= secondsPerDay;
63 const std::size_t hours = iSeconds / secondsPerHour;
65 iSeconds %= secondsPerHour;
66 const std::size_t minutes = iSeconds / secondsPerMinute;
70 const double dSeconds = fmod( totalSeconds, 60.0 );
74 std::ostringstream make_string(
"" );
75 if( days != 0 ){ make_string << days <<
"d"; nonzero =
true; }
76 if( hours != 0 || nonzero ){ make_string << hours <<
"h"; nonzero =
true; }
77 if( minutes != 0 || nonzero ){ make_string << minutes <<
"m"; nonzero =
true; }
78 make_string << std::showpoint << std::fixed << std::setprecision( precision );
79 make_string << dSeconds <<
"s";
82 return make_string.str();
91 time_t rawtime = time( NULL );
93 struct tm * timeinfo = localtime( &rawtime );
95 std::string timeAsString = std::string( asctime( timeinfo ) );
97 timeAsString.erase( timeAsString.end() - 1 );
std::string GetCurrentDateAndTime(void)
std::string ConvertSecondsToDHMS(const double totalSeconds, const unsigned int precision=0)