summaryrefslogtreecommitdiff
path: root/src/base/time.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/time.cc')
-rw-r--r--src/base/time.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/base/time.cc b/src/base/time.cc
index 8ce2e2137..dd9e72a09 100644
--- a/src/base/time.cc
+++ b/src/base/time.cc
@@ -28,6 +28,8 @@
* Authors: Nathan Binkert
*/
+#include <cstdlib>
+#include <ctime>
#include <iostream>
#include <sstream>
@@ -144,3 +146,22 @@ sleep(const Time &time)
nanosleep(&ts, NULL);
#endif
}
+
+time_t
+mkutctime(struct tm *time)
+{
+ time_t ret;
+ char *tz;
+
+ tz = getenv("TZ");
+ setenv("TZ", "", 1);
+ tzset();
+ ret = mktime(time);
+ if (tz)
+ setenv("TZ", tz, 1);
+ else
+ unsetenv("TZ");
+ tzset();
+ return ret;
+}
+