userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
timepoint_tz.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <chrono>
8
#include <string>
9
10
#include <
userver/logging/log_helper_fwd.hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
utils::datetime
{
15
16
class
TimePointTzBase {
17
public
:
18
using
TimePoint = std::chrono::system_clock::time_point;
19
20
constexpr
TimePointTzBase() =
default
;
21
constexpr
explicit
TimePointTzBase(TimePoint tp)
22
: tp_(tp)
23
{}
24
constexpr
TimePointTzBase(TimePoint tp, std::chrono::seconds tz_offset)
25
: tp_(tp),
26
tz_offset_(tz_offset)
27
{}
28
TimePointTzBase(
const
TimePointTzBase& other);
29
TimePointTzBase(TimePointTzBase&& other)
noexcept
;
30
31
TimePointTzBase& operator=(
const
TimePointTzBase& other);
32
TimePointTzBase& operator=(TimePointTzBase&& other)
noexcept
;
33
34
// Deliberately no 'explicit' to be compatible with legacy util/swaggen's
35
// plain time_point types
36
operator
TimePoint()
const
;
37
39
std::chrono::seconds
GetTzOffset
() const noexcept;
40
42
TimePoint
GetTimePoint
() const noexcept;
43
44
bool
operator==(const TimePointTzBase& other) const;
45
46
bool
operator<(const TimePointTzBase& other) const;
47
48
bool
operator>(const TimePointTzBase& other) const;
49
50
bool
operator<=(const TimePointTzBase& other) const;
51
52
bool
operator>=(const TimePointTzBase& other) const;
53
54
private:
55
TimePoint tp_{};
56
std::chrono::seconds tz_offset_{};
57
};
58
59
bool
operator<(
const
TimePointTzBase::TimePoint& lhs,
const
TimePointTzBase& rhs);
60
61
bool
operator>(
const
TimePointTzBase::TimePoint& lhs,
const
TimePointTzBase& rhs);
62
63
bool
operator<=(
const
TimePointTzBase::TimePoint& lhs,
const
TimePointTzBase& rhs);
64
65
bool
operator>=(
const
TimePointTzBase::TimePoint& lhs,
const
TimePointTzBase& rhs);
66
68
class
TimePointTzFraction final :
public
TimePointTzBase {
69
using
TimePointTzBase::TimePointTzBase;
70
71
explicit
TimePointTzFraction(
const
std::string& timestring);
72
};
73
74
logging::LogHelper
& operator<<(
logging::LogHelper
& os,
const
TimePointTzFraction
& v);
75
77
class
TimePointTz final :
public
TimePointTzBase {
78
using
TimePointTzBase::TimePointTzBase;
79
80
explicit
TimePointTz(
const
std::string& timestring);
81
};
82
83
logging::LogHelper
& operator<<(
logging::LogHelper
& os,
const
TimePointTz
& v);
84
86
class
TimePointTzIsoBasic final :
public
TimePointTzBase {
87
using
TimePointTzBase::TimePointTzBase;
88
89
explicit
TimePointTzIsoBasic(
const
std::string& timestring);
90
};
91
92
logging::LogHelper
& operator<<(
logging::LogHelper
& os,
const
TimePointTzIsoBasic
& v);
93
94
}
// namespace utils::datetime
95
96
USERVER_NAMESPACE_END
userver
utils
datetime
timepoint_tz.hpp
Generated on
for userver by
Doxygen
1.17.0