userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
timestamp.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/logging/timestamp.hpp
4
/// @brief Coroutine-safe date and time formatting utilities
5
/// @ingroup userver_universal
6
7
#
include
<
chrono
>
8
#
include
<
cstddef
>
9
#
include
<
string_view
>
10
11
#
include
<
userver
/
compiler
/
impl
/
lifetime
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
logging
{
16
17
/// A fixed-size date and time string in `YYYY-MM-DDTHH:MM:SS` format.
18
///
19
/// The contents are not null-terminated. Use ToStringView() to access them.
20
struct
TimeString
final
{
21
static
constexpr
std::size_t kSize =
sizeof
(
"0000-00-00T00:00:00"
) - 1;
22
23
char
data[kSize]{};
24
25
std::string_view ToStringView()
const
noexcept
USERVER_IMPL_LIFETIME_BOUND {
return
{data,
sizeof
(data)}; }
26
};
27
28
/// @brief Formats @p time in UTC as `YYYY-MM-DDTHH:MM:SS`.
29
///
30
/// This function is coroutine-safe and does not block. It caches the formatted
31
/// value in coroutine-safe thread-local storage.
32
TimeString
GetCurrentGMTimeString
(std::chrono::system_clock::time_point time)
noexcept
;
33
34
/// @brief Formats @p time in the system local timezone as `YYYY-MM-DDTHH:MM:SS`.
35
///
36
/// This function is coroutine-safe and does not block. It caches the formatted
37
/// value in coroutine-safe thread-local storage.
38
TimeString
GetCurrentLocalTimeString
(std::chrono::system_clock::time_point time)
noexcept
;
39
40
namespace
impl {
41
42
std::chrono::microseconds::rep FractionalMicroseconds(std::chrono::system_clock::time_point time)
noexcept
;
43
44
}
// namespace impl
45
46
}
// namespace logging
47
48
USERVER_NAMESPACE_END
userver
logging
timestamp.hpp
Generated on
for userver by
Doxygen
1.17.0