diff options
Diffstat (limited to 'src/timer/timer.cpp')
-rw-r--r-- | src/timer/timer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp index e3e3c5a16..16d7dc368 100644 --- a/src/timer/timer.cpp +++ b/src/timer/timer.cpp @@ -19,6 +19,19 @@ u64bit system_time() return static_cast<u64bit>(std::time(0)); } +/* +* Convert a time_t to a struct tm +*/ +std::tm time_t_to_tm(u64bit timer) + { + std::time_t time_val = static_cast<std::time_t>(timer); + + std::tm* tm_p = std::gmtime(&time_val); + if (tm_p == 0) + throw Encoding_Error("time_t_to_tm could not convert"); + return (*tm_p); + } + /** * Read the clock and return the output */ |