@@ -77,8 +77,37 @@ _NODISCARD basic_string<typename _Traits::char_type, _Traits, _Alloc> _Convert_w
7777}
7878#endif // _HAS_CXX17
7979
80- #if _HAS_CXX20
8180namespace chrono {
81+ _EXPORT_STD struct system_clock { // wraps GetSystemTimePreciseAsFileTime
82+ using rep = long long;
83+ using period = ratio<1, 10'000'000>; // 100 nanoseconds
84+ using duration = _CHRONO duration<rep, period>;
85+ using time_point = _CHRONO time_point<system_clock>;
86+ static constexpr bool is_steady = false;
87+
88+ _NODISCARD static time_point now() noexcept { // get current time
89+ return time_point(duration(_Xtime_get_ticks()));
90+ }
91+
92+ _NODISCARD static __time64_t to_time_t(const time_point& _Time) noexcept { // convert to __time64_t
93+ return duration_cast<seconds>(_Time.time_since_epoch()).count();
94+ }
95+
96+ _NODISCARD static time_point from_time_t(__time64_t _Tm) noexcept { // convert from __time64_t
97+ return time_point{seconds{_Tm}};
98+ }
99+ };
100+
101+ #if _HAS_CXX20
102+ _EXPORT_STD template <class _Duration>
103+ using sys_time = time_point<system_clock, _Duration>;
104+ _EXPORT_STD using sys_seconds = sys_time<seconds>;
105+ _EXPORT_STD using sys_days = sys_time<days>;
106+ #endif // _HAS_CXX20
107+
108+ _EXPORT_STD using high_resolution_clock = steady_clock;
109+
110+ #if _HAS_CXX20
82111 // [time.duration.io]
83112
84113#define _IF_PERIOD_RETURN_SUFFIX_ELSE(_TYPE, _SUFFIX) \
@@ -2758,8 +2787,10 @@ namespace chrono {
27582787 return gps_time<common_type_t<_Duration, seconds>>{_Time.time_since_epoch()} + _Gps_epoch_adjust;
27592788 }
27602789 };
2790+ #endif // _HAS_CXX20
27612791} // namespace chrono
27622792
2793+ #if _HAS_CXX20
27632794namespace filesystem {
27642795 struct _File_time_clock;
27652796} // namespace filesystem
@@ -6119,19 +6150,84 @@ namespace chrono {
61196150 return _STD move(_Os).str();
61206151 }
61216152} // namespace chrono
6153+ #endif // _HAS_CXX20
61226154
61236155inline namespace literals {
61246156 inline namespace chrono_literals {
6157+ _EXPORT_STD _NODISCARD constexpr _CHRONO hours operator""h(unsigned long long _Val) noexcept
6158+ /* strengthened */ {
6159+ return _CHRONO hours(_Val);
6160+ }
6161+
6162+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double, ratio<3600>> operator""h(long double _Val) noexcept
6163+ /* strengthened */ {
6164+ return _CHRONO duration<double, ratio<3600>>(_Val);
6165+ }
6166+
6167+ _EXPORT_STD _NODISCARD constexpr _CHRONO minutes operator""min(unsigned long long _Val) noexcept
6168+ /* strengthened */ {
6169+ return _CHRONO minutes(_Val);
6170+ }
6171+
6172+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double, ratio<60>> operator""min(long double _Val) noexcept
6173+ /* strengthened */ {
6174+ return _CHRONO duration<double, ratio<60>>(_Val);
6175+ }
6176+
6177+ _EXPORT_STD _NODISCARD constexpr _CHRONO seconds operator""s(unsigned long long _Val) noexcept
6178+ /* strengthened */ {
6179+ return _CHRONO seconds(_Val);
6180+ }
6181+
6182+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double> operator""s(long double _Val) noexcept
6183+ /* strengthened */ {
6184+ return _CHRONO duration<double>(_Val);
6185+ }
6186+
6187+ _EXPORT_STD _NODISCARD constexpr _CHRONO milliseconds operator""ms(unsigned long long _Val) noexcept
6188+ /* strengthened */ {
6189+ return _CHRONO milliseconds(_Val);
6190+ }
6191+
6192+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double, milli> operator""ms(long double _Val) noexcept
6193+ /* strengthened */ {
6194+ return _CHRONO duration<double, milli>(_Val);
6195+ }
6196+
6197+ _EXPORT_STD _NODISCARD constexpr _CHRONO microseconds operator""us(unsigned long long _Val) noexcept
6198+ /* strengthened */ {
6199+ return _CHRONO microseconds(_Val);
6200+ }
6201+
6202+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double, micro> operator""us(long double _Val) noexcept
6203+ /* strengthened */ {
6204+ return _CHRONO duration<double, micro>(_Val);
6205+ }
6206+
6207+ _EXPORT_STD _NODISCARD constexpr _CHRONO nanoseconds operator""ns(unsigned long long _Val) noexcept
6208+ /* strengthened */ {
6209+ return _CHRONO nanoseconds(_Val);
6210+ }
6211+
6212+ _EXPORT_STD _NODISCARD constexpr _CHRONO duration<double, nano> operator""ns(long double _Val) noexcept
6213+ /* strengthened */ {
6214+ return _CHRONO duration<double, nano>(_Val);
6215+ }
6216+
6217+ #if _HAS_CXX20
61256218 _EXPORT_STD _NODISCARD constexpr _CHRONO day operator""d(unsigned long long _Day) noexcept {
61266219 return _CHRONO day{static_cast<unsigned int>(_Day)};
61276220 }
61286221 _EXPORT_STD _NODISCARD constexpr _CHRONO year operator""y(unsigned long long _Year) noexcept {
61296222 return _CHRONO year{static_cast<int>(_Year)};
61306223 }
6224+ #endif // _HAS_CXX20
61316225 } // namespace chrono_literals
61326226} // namespace literals
6133- #endif // _HAS_CXX20
61346227
6228+ namespace chrono {
6229+ _EXPORT_STD using namespace literals::chrono_literals;
6230+ } // namespace chrono
61356231_STD_END
61366232#pragma pop_macro("new")
61376233_STL_RESTORE_CLANG_WARNINGS
0 commit comments