|
23 | 23 | #include <Helpers/Format.hpp> |
24 | 24 | #include <Helpers/Integer.hpp> |
25 | 25 | #include <Helpers/String.hpp> |
| 26 | +#include <Helpers/Time.hpp> |
26 | 27 | #include <IniParser/Ini.hpp> |
27 | 28 | #include <LuaLibrary.hpp> |
28 | 29 | #include <LuaType/LuaCustomProperty.hpp> |
@@ -213,26 +214,7 @@ namespace RC |
213 | 214 | { |
214 | 215 | m_console_device = &Output::set_default_devices<Output::ConsoleDevice>(); |
215 | 216 | m_console_device->set_formatter([](File::StringViewType string) -> File::StringType { |
216 | | - bool use_local_time = true; |
217 | | -#ifdef _WIN32 |
218 | | - if (auto module = GetModuleHandleW(L"ntdll.dll"); module && GetProcAddress(module, "wine_get_version")) |
219 | | - { |
220 | | - use_local_time = false; |
221 | | - } |
222 | | -#endif |
223 | | - if (use_local_time) |
224 | | - { |
225 | | - static const auto timezone = std::chrono::current_zone(); |
226 | | - return fmt::format(STR("[{}] {}"), |
227 | | - fmt::format(STR("{:%X}"), |
228 | | - std::chrono::time_point_cast<std::chrono::system_clock::duration>( |
229 | | - timezone->to_local(std::chrono::system_clock::now()))), |
230 | | - string); |
231 | | - } |
232 | | - else |
233 | | - { |
234 | | - return fmt::format(STR("[{}] {}"), fmt::format(STR("{:%X}"), std::chrono::system_clock::now()), string); |
235 | | - } |
| 217 | + return fmt::format(STR("[{}] {}"), get_now_as_string(STR("{:%X}")), string); |
236 | 218 | }); |
237 | 219 | if (settings_manager.Debug.DebugConsoleVisible) |
238 | 220 | { |
@@ -279,7 +261,14 @@ namespace RC |
279 | 261 | #endif |
280 | 262 | if (use_local_time) |
281 | 263 | { |
282 | | - Output::send(STR("Timezone: {}\n"), ensure_str(std::chrono::current_zone()->name())); |
| 264 | + try |
| 265 | + { |
| 266 | + Output::send(STR("Timezone: {}\n"), ensure_str(std::chrono::current_zone()->name())); |
| 267 | + } |
| 268 | + catch (std::runtime_error&) |
| 269 | + { |
| 270 | + Output::send(STR("Timezone: UTC (local disabled due to lack of support (chrono::current_zone() failed))\n")); |
| 271 | + } |
283 | 272 | } |
284 | 273 | else |
285 | 274 | { |
@@ -523,26 +512,7 @@ namespace RC |
523 | 512 | m_debug_console_device = &Output::set_default_devices<Output::DebugConsoleDevice>(); |
524 | 513 | Output::set_default_log_level<LogLevel::Normal>(); |
525 | 514 | m_debug_console_device->set_formatter([](File::StringViewType string) -> File::StringType { |
526 | | - bool use_local_time = true; |
527 | | -#ifdef _WIN32 |
528 | | - if (auto module = GetModuleHandleW(L"ntdll.dll"); module && GetProcAddress(module, "wine_get_version")) |
529 | | - { |
530 | | - use_local_time = false; |
531 | | - } |
532 | | -#endif |
533 | | - if (use_local_time) |
534 | | - { |
535 | | - static const auto timezone = std::chrono::current_zone(); |
536 | | - return fmt::format(STR("[{}] {}"), |
537 | | - fmt::format(STR("{:%X}"), |
538 | | - std::chrono::time_point_cast<std::chrono::system_clock::duration>( |
539 | | - timezone->to_local(std::chrono::system_clock::now()))), |
540 | | - string); |
541 | | - } |
542 | | - else |
543 | | - { |
544 | | - return fmt::format(STR("[{}] {}"), fmt::format(STR("{:%X}"), std::chrono::system_clock::now()), string); |
545 | | - } |
| 515 | + return fmt::format(STR("[{}] {}"), get_now_as_string(STR("{:%X}")), string); |
546 | 516 | }); |
547 | 517 |
|
548 | 518 | if (AllocConsole()) |
|
0 commit comments