Skip to content
Snippets Groups Projects

Profile certificates

Merged Daniel Lyubomirov requested to merge profile-certificates into master
1 unresolved thread
63 files
+ 1954
190
Compare changes
  • Side-by-side
  • Inline
Files
63
+ 73
0
#include <vereign/core/time.hh>
namespace vereign::time {
auto Epoch() -> boost::posix_time::ptime {
static const auto epoch = boost::posix_time::ptime{boost::gregorian::date{1970, 1, 1}};
return epoch;
}
auto PosixTimeToTime(boost::posix_time::ptime t) -> time_t {
return time_t((t - Epoch()).total_seconds());
}
auto MakePosixTime(
int year,
int month,
int day,
int hours,
int minutes,
int seconds
) -> boost::posix_time::ptime {
using namespace boost::posix_time;
using namespace boost::gregorian;
return ptime(
date{
static_cast<date::year_type>(year),
static_cast<date::month_type>(month),
static_cast<date::day_type>(day)
},
time_duration(hours, minutes, seconds)
);
}
auto MakeTimeUTC(
int year,
int month,
int day,
int hours,
int seconds,
int milliseconds
) -> time_t {
using namespace boost::posix_time;
using namespace boost::gregorian;
return PosixTimeToTime(
ptime(
date{
static_cast<date::year_type>(year),
static_cast<date::month_type>(month),
static_cast<date::day_type>(day)
},
time_duration(hours, seconds, milliseconds)
)
);
}
auto MakeTimeUTCFromString(const std::string& str) -> time_t {
using namespace boost::posix_time;
using namespace boost::gregorian;
return PosixTimeToTime(boost::posix_time::time_from_string(str));
}
auto MakeTimeUTCFromISO(const std::string& str) -> time_t {
using namespace boost::posix_time;
using namespace boost::gregorian;
return PosixTimeToTime(from_iso_string(str));
}
} // vereign::time
Loading