12 # include <vcl_msvc_warnings.h> 15 #if defined(_WIN32) && !defined(__CYGWIN__) 21 #include <vcl_sys/time.h> 27 #if !defined(_WIN32) || defined(__CYGWIN__) 31 struct timeval timestamp;
32 struct timezone* dummy =
nullptr;
33 gettimeofday(×tamp, dummy);
35 secs = timestamp.tv_sec;
36 msecs = timestamp.tv_usec/1000;
45 secs = static_cast<int>(real.time);
57 std::time_t time_secs;
58 std::time(&time_secs);
62 time = std::localtime(&time_secs);
72 std::ostringstream oss;
74 oss << std::setw(4) << 1900+time->tm_year <<
' ' 75 << std::setw(2) << 1 + time->tm_mon <<
' ' 76 << std::setw(2) << time->tm_mday <<
' ' 77 << std::setw(2) << time->tm_hour <<
' ' 78 << std::setw(2) << time->tm_min <<
' ' 79 << std::setw(2) << time->tm_sec;
88 timestr = std::asctime(time);
Utility functions for C strings and std::strings.
void vul_get_timestamp(int &secs, int &msecs)
purpose: obtain time elapsed since 1 Jan 1970, in seconds and milliseconds.
vul_time_style
Enum to specify style option for vul_get_time_as_string().
std::string & vul_string_right_trim(std::string &sr, const char *rem)
Removes any suffix occurrence of rem from str and returns modified string.
Obtains time elapsed since 1 Jan 1970, in seconds and milliseconds.
space-separated numbers, most significant first "e.g. 2006 12 08 14 54 17"
std::string vul_get_time_as_string(vul_time_style style)
Get the present time and date as a string, e.g. "Fri Dec 8 14:54:17 2006".