13#include <cctz/civil_time.h>
15USERVER_NAMESPACE_BEGIN
22inline constexpr std::time_t kStartOfTheEpoch = 0;
30inline const std::string
kIsoFormat =
"%Y-%m-%dT%H:%M:%SZ";
32using timepair_t = std::pair<std::uint8_t, std::uint8_t>;
37 DateParseError(
const std::string& timestring);
43 TimezoneLookupError(
const std::string& tzname);
50std::chrono::system_clock::time_point
Now()
noexcept;
54std::chrono::system_clock::time_point
Epoch()
noexcept;
65std::chrono::steady_clock::time_point
SteadyNow()
noexcept;
70 using time_point = std::chrono::steady_clock::time_point;
72 static time_point now() {
return SteadyNow(); }
76bool IsTimeBetween(
int hour,
int min,
int hour_from,
int min_from,
int hour_to,
77 int min_to,
bool include_time_to =
false)
noexcept;
107std::string
Timestring(std::chrono::system_clock::time_point tp,
127 const std::string& timestring,
136 const std::string& timestring,
const std::string& format =
kDefaultFormat);
146 const std::string& timestamp,
const std::string& timezone);
151 const std::string& timestamp);
161 const std::string& timestring,
170std::time_t
Timestamp(std::chrono::system_clock::time_point tp)
noexcept;
187cctz::civil_second
Localize(
const std::chrono::system_clock::time_point& tp,
188 const std::string& timezone);
193 const std::chrono::system_clock::time_point& tp);
202 const std::string& timezone);
219 const std::chrono::system_clock::time_point& tp)
noexcept;
223 std::int64_t ticks)
noexcept;
226template <
class Duration,
class Clock>
228 const std::chrono::time_point<Clock>& b) {
229 const auto duration_a = a.time_since_epoch();
230 const auto duration_b = b.time_since_epoch();
231 return std::chrono::duration_cast<Duration>(duration_a - duration_b).count();