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(const std::string& timestring);
20
21/// @brief Converts strings of the specified format starting with "%Y" to
22/// std::chrono::system_clock::time_point in UTC timezone and saturates on
23/// overflow.
24std::chrono::system_clock::time_point FromStringSaturating(const std::string& timestring, const std::string& format);
25
26} // namespace utils::datetime
27
28USERVER_NAMESPACE_END