diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/time.cc | 21 | ||||
-rw-r--r-- | src/base/time.hh | 2 |
2 files changed, 23 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; +} + diff --git a/src/base/time.hh b/src/base/time.hh index f2107d78f..734a86fa9 100644 --- a/src/base/time.hh +++ b/src/base/time.hh @@ -268,4 +268,6 @@ operator<<(std::ostream &out, const Time &time) return out; } +time_t mkutctime(struct tm *time); + #endif // __BASE_TIME_HH__ |