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(); }
83 bool include_time_to =
false
97 std::time_t timestamp,
116 std::chrono::system_clock::time_point tp,
137 const std::string& timestring,
146std::chrono::system_clock::time_point
156std::chrono::system_clock::time_point
GuessStringtime(
const std::string& timestamp,
const std::string& timezone);
170 const std::string& timestring,
180std::time_t
Timestamp(std::chrono::system_clock::time_point tp)
noexcept;
197cctz::civil_second
Localize(
const std::chrono::system_clock::time_point& tp,
const std::string& timezone);
209std::time_t
Unlocalize(
const cctz::civil_second& local_tp,
const std::string& timezone);
231template <
class Duration,
class Clock>
232double CalcTimeDiff(
const std::chrono::time_point<Clock>& a,
const std::chrono::time_point<Clock>& b) {
233 const auto duration_a = a.time_since_epoch();
234 const auto duration_b = b.time_since_epoch();
235 return std::chrono::duration_cast<Duration>(duration_a - duration_b).count();