From 285313cc68a860e84acd932a59102e2aed1b8e9e Mon Sep 17 00:00:00 2001 From: Igor Pissolati Date: Mon, 28 Apr 2025 17:20:37 -0300 Subject: [PATCH] Add test for TimeZoneInformation --- src/samples/test-sample/test.cpp | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/samples/test-sample/test.cpp b/src/samples/test-sample/test.cpp index 7923e6d1..70f909b2 100644 --- a/src/samples/test-sample/test.cpp +++ b/src/samples/test-sample/test.cpp @@ -458,6 +458,48 @@ namespace return true; } + bool test_time_zone() + { + DYNAMIC_TIME_ZONE_INFORMATION current_dtzi = {}; + DWORD result = GetDynamicTimeZoneInformation(¤t_dtzi); + + if (result == TIME_ZONE_ID_INVALID) + { + return false; + } + + if (current_dtzi.Bias != -60 || current_dtzi.StandardBias != 0 || current_dtzi.DaylightBias != -60 || + current_dtzi.DynamicDaylightTimeDisabled != FALSE) + { + return false; + } + + if (wcscmp(current_dtzi.StandardName, L"W. Europe Standard Time") != 0 || + wcscmp(current_dtzi.DaylightName, L"W. Europe Daylight Time") != 0 || + wcscmp(current_dtzi.TimeZoneKeyName, L"W. Europe Standard Time") != 0) + { + return false; + } + + if (current_dtzi.StandardDate.wYear != 0 || current_dtzi.StandardDate.wMonth != 10 || + current_dtzi.StandardDate.wDayOfWeek != 0 || current_dtzi.StandardDate.wDay != 5 || + current_dtzi.StandardDate.wHour != 3 || current_dtzi.StandardDate.wMinute != 0 || + current_dtzi.StandardDate.wSecond != 0 || current_dtzi.StandardDate.wMilliseconds != 0) + { + return false; + } + + if (current_dtzi.DaylightDate.wYear != 0 || current_dtzi.DaylightDate.wMonth != 3 || + current_dtzi.DaylightDate.wDayOfWeek != 0 || current_dtzi.DaylightDate.wDay != 5 || + current_dtzi.DaylightDate.wHour != 2 || current_dtzi.DaylightDate.wMinute != 0 || + current_dtzi.DaylightDate.wSecond != 0 || current_dtzi.DaylightDate.wMilliseconds != 0) + { + return false; + } + + return true; + } + void throw_exception() { if (do_the_task) @@ -651,6 +693,7 @@ int main(const int argc, const char* argv[]) RUN_TEST(test_working_directory, "Working Directory") RUN_TEST(test_registry, "Registry") RUN_TEST(test_system_info, "System Info") + RUN_TEST(test_time_zone, "Time Zone") RUN_TEST(test_threads, "Threads") RUN_TEST(test_env, "Environment") RUN_TEST(test_exceptions, "Exceptions")