@@ -116,17 +116,18 @@ struct TestSuite {
116
116
117
117
[[nodiscard]] std::string to_xml () const {
118
118
std::string timestamp_str;
119
- if constexpr (requires { std::chrono::current_zone (); }) {
120
- auto localtime = std::chrono::zoned_time (std::chrono::current_zone (), timestamp).get_local_time ();
121
- timestamp_str = std::format (" {0:%F}T{0:%T}" , localtime);
122
- } else {
123
- // Cludge because macOS doesn't have std::chrono::current_zone() or std::chrono::zoned_time()
124
- std::time_t time_t_timestamp = std::chrono::system_clock::to_time_t (timestamp);
125
- std::tm localtime = *std::localtime (&time_t_timestamp);
126
- std::ostringstream oss;
127
- oss << std::put_time (&localtime, " %Y-%m-%dT%H:%M:%S" );
128
- timestamp_str = oss.str ();
129
- }
119
+ #ifdef __APPLE__
120
+ // Cludge because macOS doesn't have std::chrono::current_zone() or std::chrono::zoned_time()
121
+ std::time_t time_t_timestamp = std::chrono::system_clock::to_time_t (timestamp);
122
+ std::tm localtime = *std::localtime (&time_t_timestamp);
123
+ std::ostringstream oss;
124
+ oss << std::put_time (&localtime, " %Y-%m-%dT%H:%M:%S" );
125
+ timestamp_str = oss.str ();
126
+ #else
127
+ // Use std::chrono::current_zone() and std::chrono::zoned_time() if available (C++20)
128
+ auto localtime = std::chrono::zoned_time (std::chrono::current_zone (), timestamp).get_local_time ();
129
+ timestamp_str = std::format (" {0:%F}T{0:%T}" , localtime);
130
+ #endif
130
131
131
132
std::stringstream ss;
132
133
ss << " "
0 commit comments