23 using period = std::ratio<1, 10000000>;
24 using duration = std::chrono::duration<rep, period>;
25 using time_point = std::chrono::time_point<Clock>;
41 static constexpr
bool is_steady = std::chrono::system_clock::is_steady;
42 static time_point now() noexcept;
54 class
DateTime final : public _detail::Clock::time_point {
68 int8_t localDiffHours,
69 int8_t localDiffMinutes,
70 bool roundFracSecUp =
false);
72 void ThrowIfUnsupportedYear()
const;
74 void GetDateTimeParts(
82 int8_t* dayOfWeek)
const;
84 std::string ToStringRfc1123()
const;
112 :
DateTime(year, month, day, hour, minute, second, 0, -1, 0, 0)
120 constexpr
DateTime(time_point
const& timePoint) : time_point(timePoint) {}
127 DateTime(std::chrono::system_clock::time_point
const& systemTime)
129 SystemClockEpoch + std::chrono::duration_cast<duration>(systemTime.time_since_epoch()))
139 explicit operator std::chrono::system_clock::time_point()
const;
182 static DateTime Parse(std::string
const& dateTime, DateFormat format);
191 std::string ToString(DateFormat format = DateFormat::Rfc3339)
const;
202 std::string ToString(DateFormat format, TimeFractionFormat fractionFormat)
const;
205 inline _detail::Clock::time_point _detail::Clock::now() noexcept
207 return DateTime(std::chrono::system_clock::now());
210 inline bool operator==(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
212 return dt == DateTime(tp);
215 inline bool operator<(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
217 return dt < DateTime(tp);
220 inline bool operator<=(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
222 return dt <= DateTime(tp);
225 inline bool operator!=(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
230 inline bool operator>(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
235 inline bool operator>=(DateTime
const& dt, std::chrono::system_clock::time_point
const& tp)
240 inline bool operator==(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
245 inline bool operator!=(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
250 inline bool operator<(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
255 inline bool operator<=(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
260 inline bool operator>(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
265 inline bool operator>=(std::chrono::system_clock::time_point
const& tp, DateTime
const& dt)
270 namespace Core {
namespace _internal {
275 class PosixTimeConverter final {
283 static DateTime PosixTimeToDateTime(int64_t posixTime)
285 return {DateTime(1970) + std::chrono::seconds(posixTime)};
294 static int64_t DateTimeToPosixTime(DateTime
const& dateTime)
297 return std::chrono::duration_cast<std::chrono::seconds>(dateTime - DateTime(1970)).count();
305 PosixTimeConverter() =
delete;
312 ~PosixTimeConverter() =
delete;