@@ -77,8 +77,37 @@ _NODISCARD basic_string<typename _Traits::char_type, _Traits, _Alloc> _Convert_w
77
77
}
78
78
#endif // _HAS_CXX17
79
79
80
- #if _HAS_CXX20
81
80
namespace 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
82
111
// [time.duration.io]
83
112
84
113
#define _IF_PERIOD_RETURN_SUFFIX_ELSE(_TYPE, _SUFFIX) \
@@ -2758,8 +2787,10 @@ namespace chrono {
2758
2787
return gps_time<common_type_t<_Duration, seconds>>{_Time.time_since_epoch()} + _Gps_epoch_adjust;
2759
2788
}
2760
2789
};
2790
+ #endif // _HAS_CXX20
2761
2791
} // namespace chrono
2762
2792
2793
+ #if _HAS_CXX20
2763
2794
namespace filesystem {
2764
2795
struct _File_time_clock;
2765
2796
} // namespace filesystem
@@ -6119,19 +6150,84 @@ namespace chrono {
6119
6150
return _STD move(_Os).str();
6120
6151
}
6121
6152
} // namespace chrono
6153
+ #endif // _HAS_CXX20
6122
6154
6123
6155
inline namespace literals {
6124
6156
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
6125
6218
_EXPORT_STD _NODISCARD constexpr _CHRONO day operator""d(unsigned long long _Day) noexcept {
6126
6219
return _CHRONO day{static_cast<unsigned int>(_Day)};
6127
6220
}
6128
6221
_EXPORT_STD _NODISCARD constexpr _CHRONO year operator""y(unsigned long long _Year) noexcept {
6129
6222
return _CHRONO year{static_cast<int>(_Year)};
6130
6223
}
6224
+ #endif // _HAS_CXX20
6131
6225
} // namespace chrono_literals
6132
6226
} // namespace literals
6133
- #endif // _HAS_CXX20
6134
6227
6228
+ namespace chrono {
6229
+ _EXPORT_STD using namespace literals::chrono_literals;
6230
+ } // namespace chrono
6135
6231
_STD_END
6136
6232
#pragma pop_macro("new")
6137
6233
_STL_RESTORE_CLANG_WARNINGS
0 commit comments