aboutsummaryrefslogtreecommitdiffstats
path: root/src/timer
diff options
context:
space:
mode:
Diffstat (limited to 'src/timer')
-rw-r--r--src/timer/gettimeofday/tm_unix.cpp1
-rw-r--r--src/timer/posix_rt/tm_posix.cpp1
-rw-r--r--src/timer/timer.cpp14
-rw-r--r--src/timer/timer.h8
4 files changed, 21 insertions, 3 deletions
diff --git a/src/timer/gettimeofday/tm_unix.cpp b/src/timer/gettimeofday/tm_unix.cpp
index e32df7166..9d8ac4a04 100644
--- a/src/timer/gettimeofday/tm_unix.cpp
+++ b/src/timer/gettimeofday/tm_unix.cpp
@@ -6,7 +6,6 @@
*/
#include <botan/tm_unix.h>
-#include <botan/util.h>
#include <sys/time.h>
namespace Botan {
diff --git a/src/timer/posix_rt/tm_posix.cpp b/src/timer/posix_rt/tm_posix.cpp
index d356384ab..96182025c 100644
--- a/src/timer/posix_rt/tm_posix.cpp
+++ b/src/timer/posix_rt/tm_posix.cpp
@@ -6,7 +6,6 @@
*/
#include <botan/tm_posix.h>
-#include <botan/util.h>
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309
diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp
index 035c217f9..16d7dc368 100644
--- a/src/timer/timer.cpp
+++ b/src/timer/timer.cpp
@@ -7,7 +7,6 @@
#include <botan/timer.h>
#include <botan/loadstor.h>
-#include <botan/util.h>
#include <ctime>
namespace Botan {
@@ -20,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
*/
diff --git a/src/timer/timer.h b/src/timer/timer.h
index b6e8ef448..603027f6d 100644
--- a/src/timer/timer.h
+++ b/src/timer/timer.h
@@ -9,9 +9,17 @@
#define BOTAN_TIMERS_H__
#include <botan/rng.h>
+#include <ctime>
namespace Botan {
+/*
+* Time Access/Conversion Functions
+*/
+BOTAN_DLL u64bit system_time();
+
+BOTAN_DLL std::tm time_t_to_tm(u64bit);
+
/**
* Timer Interface
*/