9#include <botan/internal/calendar.h>
11#include <botan/assert.h>
12#include <botan/exceptn.h>
13#include <botan/internal/target_info.h>
22std::tm do_gmtime(std::time_t time_val) {
25#if defined(BOTAN_TARGET_OS_HAS_WIN32)
26 ::gmtime_s(&tm, &time_val);
27#elif defined(BOTAN_TARGET_OS_HAS_POSIX1)
28 ::gmtime_r(&time_val, &tm);
30 std::tm* tm_p = std::gmtime(&time_val);
48uint64_t days_since_epoch(uint32_t year, uint32_t month, uint32_t day) {
54 const uint32_t era = year / 400;
55 const uint32_t yoe = year - era * 400;
56 const uint32_t doy = (153 * (month + (month > 2 ? -3 : 9)) + 2) / 5 + day - 1;
57 const uint32_t doe = yoe * 365 + yoe / 4 - yoe / 100 + doy;
58 return era * 146097 + doe - 719468;
69 const time_t seconds_time_t =
static_cast<time_t
>(seconds_64);
71 if(seconds_64 - seconds_time_t != 0) {
75 return std::chrono::system_clock::from_time_t(seconds_time_t);
80 std::stringstream output;
81 output << std::setfill(
'0') << std::setw(4) <<
year() <<
"-" << std::setw(2) <<
month() <<
"-" << std::setw(2)
82 <<
day() <<
"T" << std::setw(2) <<
hour() <<
":" << std::setw(2) <<
minutes() <<
":" << std::setw(2)
88 std::tm tm = do_gmtime(std::chrono::system_clock::to_time_t(time_point));
90 m_year = tm.tm_year + 1900;
91 m_month = tm.tm_mon + 1;
94 m_minutes = tm.tm_min;
95 m_seconds = tm.tm_sec;
#define BOTAN_ARG_CHECK(expr, msg)
uint64_t seconds_since_epoch() const
std::string to_string() const
std::chrono::system_clock::time_point to_std_timepoint() const
calendar_point(uint32_t y, uint32_t mon, uint32_t d, uint32_t h, uint32_t min, uint32_t sec)