diff options
author | lloyd <[email protected]> | 2009-12-24 22:16:48 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-12-24 22:16:48 +0000 |
commit | ab35e8266cb93df950c0f93a74f9714d9de40f1c (patch) | |
tree | 66ec188b36fcb5557b56635df11cc7a59457276b /src/utils | |
parent | 6e4e7b38b837c5a5141b9dbc3aa4e5450f57865a (diff) |
Replace time_t_to_tm with calendar_value which returns a struct representing
the calendar time without tying to a particular format. From the C++0x branch.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/time.cpp | 15 | ||||
-rw-r--r-- | src/utils/time.h | 15 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/utils/time.cpp b/src/utils/time.cpp index 2de992c9d..fe4521706 100644 --- a/src/utils/time.cpp +++ b/src/utils/time.cpp @@ -76,13 +76,18 @@ u64bit system_time() } /* -* Convert a time_t to a struct tm +* Convert a time_point to a calendar_point */ -std::tm time_t_to_tm(u64bit timer) +calendar_point calendar_value(u64bit a_time_t) { - std::time_t time_val = static_cast<std::time_t>(timer); - - return do_gmtime(time_val); + std::tm tm = do_gmtime(static_cast<std::time_t>(a_time_t)); + + return calendar_point(tm.tm_year + 1900, + tm.tm_mon + 1, + tm.tm_mday, + tm.tm_hour, + tm.tm_min, + tm.tm_sec); } u64bit get_nanoseconds_clock() diff --git a/src/utils/time.h b/src/utils/time.h index c7f459096..05fc6c651 100644 --- a/src/utils/time.h +++ b/src/utils/time.h @@ -13,12 +13,25 @@ namespace Botan { +struct BOTAN_DLL calendar_point + { + u32bit year; + byte month; + byte day; + byte hour; + byte minutes; + byte seconds; + + calendar_point(u32bit y, byte mon, byte d, byte h, byte min, byte sec) : + year(y), month(mon), day(d), hour(h), minutes(min), seconds(sec) {} + }; + /* * Time Access/Conversion Functions */ BOTAN_DLL u64bit system_time(); -BOTAN_DLL std::tm time_t_to_tm(u64bit); +BOTAN_DLL calendar_point calendar_value(u64bit a_time_t); /** @return nanoseconds resolution timestamp, unknown epoch |