#include <string>
#include <sstream>
#include <iomanip>
#include <ctime>
Go to the source code of this file.
|
AMREX_FORCE_INLINE std::time_t | getEpochTime (const std::string &dateTime, const std::string &dateTimeFormat) |
|
AMREX_FORCE_INLINE std::string | getTimestamp (const amrex::Real epoch_real, const std::string &datetime_format) |
|
◆ getEpochTime()
AMREX_FORCE_INLINE std::time_t getEpochTime |
( |
const std::string & |
dateTime, |
|
|
const std::string & |
dateTimeFormat |
|
) |
| |
19 if (sscanf(dateTime.c_str(),
"%d-%d-%d_%d:%d:%dUTC",
20 &tmTime.tm_year, &tmTime.tm_mon, &tmTime.tm_mday,
21 &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec) != 6) {
26 tmTime.tm_year -= 1900;
30 return timegm(&tmTime);
Referenced by ERF::ReadParameters().
◆ getTimestamp()
AMREX_FORCE_INLINE std::string getTimestamp |
( |
const amrex::Real |
epoch_real, |
|
|
const std::string & |
datetime_format |
|
) |
| |
37 auto epoch_nearest_sec =
static_cast<std::time_t
>(epoch_real);
38 std::tm *time_info = std::gmtime(&epoch_nearest_sec);
41 std::strftime(buffer,
sizeof(buffer), datetime_format.c_str(), time_info);
42 std::string str_nearest_sec(buffer);
44 double frac_sec = epoch_real - epoch_nearest_sec;
45 snprintf(buffer, 80,
"%.6f", frac_sec);
46 AMREX_ASSERT(buffer[0] ==
'0');
47 std::string str_frac_sec(buffer);
49 return str_nearest_sec + str_frac_sec.substr(1);
Referenced by ERF::Evolve().