userver: userver/utils/datetime/from_string_saturating.hpp Source File
Loading...
Searching...
No Matches
from_string_saturating.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/datetime/from_string_saturating.hpp
4/// @brief Saturating converters from strings to time points.
5/// @ingroup userver_universal
6
7#include <chrono>
8#include <string>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace utils::datetime {
13
14/// @brief Converts strings like "2012-12-12T00:00:00" to
15/// std::chrono::system_clock::time_point in UTC timezone and saturates on
16/// overflow
17/// Example:
18/// @snippet utils/datetime/from_string_saturating_test.cpp FromStringSaturation
19std::chrono::system_clock::time_point FromRfc3339StringSaturating(
20 const std::string& timestring);
21
22/// @brief Converts strings of the specified format starting with "%Y" to
23/// std::chrono::system_clock::time_point in UTC timezone and saturates on
24/// overflow.
25std::chrono::system_clock::time_point FromStringSaturating(
26 const std::string& timestring, const std::string& format);
27
28} // namespace utils::datetime
29
30USERVER_NAMESPACE_END