diff options
author | lloyd <[email protected]> | 2009-12-01 13:28:16 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-12-01 13:28:16 +0000 |
commit | fe0276ee115bb367810ac2e06833fed297eb1715 (patch) | |
tree | 2adf34a771c5dc460f559deb33afd29501fea802 /src/asn1 | |
parent | 4aec044fc21526e1c9185b384f7e984b7f8622c7 (diff) |
Remove system_time(), replace entirely with std::chrono.
Only remaining use of time.h/ctime is to convert from a time point to
a calendar value, which still requires C's gmtime. Hide it entirely in
time.cpp and return a calendar_point struct instead of a std::tm.
Diffstat (limited to 'src/asn1')
-rw-r--r-- | src/asn1/asn1_obj.h | 3 | ||||
-rw-r--r-- | src/asn1/asn1_tm.cpp | 20 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/asn1/asn1_obj.h b/src/asn1/asn1_obj.h index ea21c475f..a640f712b 100644 --- a/src/asn1/asn1_obj.h +++ b/src/asn1/asn1_obj.h @@ -14,6 +14,7 @@ #include <botan/alg_id.h> #include <vector> #include <map> +#include <chrono> namespace Botan { @@ -52,7 +53,7 @@ class BOTAN_DLL X509_Time : public ASN1_Object void set_to(const std::string&); void set_to(const std::string&, ASN1_Tag); - X509_Time(u64bit); + X509_Time(const std::chrono::system_clock::time_point& time); X509_Time(const std::string& = ""); X509_Time(const std::string&, ASN1_Tag); private: diff --git a/src/asn1/asn1_tm.cpp b/src/asn1/asn1_tm.cpp index 9df10f4a3..6e56bb8d1 100644 --- a/src/asn1/asn1_tm.cpp +++ b/src/asn1/asn1_tm.cpp @@ -23,18 +23,18 @@ X509_Time::X509_Time(const std::string& time_str) } /* -* Create an X509_Time +* Create a X509_Time from a time point */ -X509_Time::X509_Time(u64bit timer) +X509_Time::X509_Time(const std::chrono::system_clock::time_point& time) { - std::tm time_info = time_t_to_tm(timer); - - year = time_info.tm_year + 1900; - month = time_info.tm_mon + 1; - day = time_info.tm_mday; - hour = time_info.tm_hour; - minute = time_info.tm_min; - second = time_info.tm_sec; + calendar_point cal = calendar_value(time); + + year = cal.year; + month = cal.month; + day = cal.day; + hour = cal.hour; + minute = cal.minutes; + second = cal.seconds; if(year >= 2050) tag = GENERALIZED_TIME; |