blob: 656b318f986a309abd4d37979ebf97a4828c8862 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <chrono>
#include <string>
#include <logger/logger.hpp>
class DateTime
{
public:
enum class Engine {
Postgresql,
Sqlite3,
} engine{Engine::Sqlite3};
using time_point = std::chrono::system_clock::time_point;
DateTime():
s{},
t{}
{ }
DateTime(std::time_t t):
t(std::chrono::seconds(t))
{}
DateTime(std::string s):
s(std::move(s))
{}
DateTime& operator=(const std::string& s)
{
this->s = s;
return *this;
}
DateTime& operator=(const time_point t)
{
this->t = t;
return *this;
}
const std::string& to_string() const
{
return this->s;
}
time_point::duration epoch() const
{
return this->t.time_since_epoch();
}
private:
std::string s;
time_point t;
};
|