diff options
author | lloyd <[email protected]> | 2009-10-13 21:27:28 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-13 21:27:28 +0000 |
commit | 92f31b22dfe2aa1b2bde84cbaf4ce7365fa4ec68 (patch) | |
tree | 05696295d78dee44d115611ac9342666a9a34dd7 /src/utils | |
parent | f1980faa1240116b069de2dbbe36353765422b39 (diff) |
Attic-ize all of src/timer, except for time_t_to_tm and system_time
(which will go later) which will live in the new time.h
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/time.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/utils/time.h b/src/utils/time.h new file mode 100644 index 000000000..3052aec44 --- /dev/null +++ b/src/utils/time.h @@ -0,0 +1,39 @@ +/* +* Time Functions +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_TIME_OPS_H__ +#define BOTAN_TIME_OPS_H__ + +#include <ctime> + +namespace Botan { + +/* +* Convert a time_t value to a struct tm +*/ +inline std::tm time_t_to_tm(u64bit time_int) + { + std::time_t time_val = static_cast<std::time_t>(time_int); + + 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); + } + +/** +* Get the system clock +*/ +inline u64bit system_time() + { + return static_cast<u64bit>(std::time(0)); + } + +} + + +#endif |