memgraph/include/utils/datetime/datetime.hpp
2016-08-10 09:39:02 +01:00

36 lines
520 B
C++

#pragma once
#include "utils/exceptions/basic_exception.hpp"
class Datetime
{
public:
Datetime()
{
}
Datetime(std::time_t time_point)
{
auto result = gmtime_r(&time_point, &time);
if(result == nullptr)
throw DatetimeError("Unable to construct from {}", time_point);
}
Datetime(const Datetime&) = default;
Datetime(Datetime&&) = default;
static Datetime now()
{
timespec
return Datetime();
}
private:
std::tm time;
};