ReactOS 0.4.15-dev-7924-g5949c20
RtlQueryTimeZoneInfo.c File Reference
#include "precomp.h"
Include dependency graph for RtlQueryTimeZoneInfo.c:

Go to the source code of this file.

Functions

static NTSTATUS (WINAPI *pRtlQueryTimeZoneInformation)(RTL_TIME_ZONE_INFORMATION *)
 
static void test_RtlQueryTimeZoneInformation (void)
 
 START_TEST (RtlQueryTimeZoneInformation)
 

Function Documentation

◆ NTSTATUS()

static NTSTATUS ( WINAPI pRtlQueryTimeZoneInformation)
static

◆ START_TEST()

START_TEST ( RtlQueryTimeZoneInformation  )

Definition at line 148 of file RtlQueryTimeZoneInfo.c.

149{
150 /* Test modeled after reactos\modules\rostests\winetests\ntdll\time.c for Vista+ */
151 HMODULE mod = GetModuleHandleA("ntdll.dll");
152 pRtlQueryTimeZoneInformation = (void *)GetProcAddress(mod, "RtlQueryTimeZoneInformation");
153
155}
static void test_RtlQueryTimeZoneInformation(void)
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static int mod
Definition: i386-dis.c:1288

◆ test_RtlQueryTimeZoneInformation()

static void test_RtlQueryTimeZoneInformation ( void  )
static

Definition at line 49 of file RtlQueryTimeZoneInfo.c.

50{
53 TIME_ZONE_INFORMATION tziOld, tziNew, tziTest;
54 DWORD dwRet;
55
56 // Retrieve the current time zone information
57
58 dwRet = GetTimeZoneInformation(&tziOld);
59
61 "Get Time Zone Name failed with error = %ld.\n", GetLastError());
62
63 // Adjust the time zone information
64
65 ZeroMemory(&tziNew, sizeof(tziNew));
66 tziNew.Bias = 360;
67 wcscpy(tziNew.StandardName, L"Test Standard Zone");
68 tziNew.StandardDate.wMonth = 11;
69 tziNew.StandardDate.wDayOfWeek = 5;
70 tziNew.StandardDate.wDay = 3;
71 tziNew.StandardDate.wHour = 2;
72 tziNew.StandardBias = 120;
73
74 wcscpy(tziNew.DaylightName, L"Test Daylight Zone");
75 tziNew.DaylightDate.wMonth = 4;
76 tziNew.DaylightDate.wDayOfWeek = 6;
77 tziNew.DaylightDate.wDay = 2;
78 tziNew.DaylightDate.wHour = 2;
79 tziNew.DaylightBias = -60;
80
81 // Set up SetLastError with known value for later testing
82
83 SetLastError(0xDEADBEEF);
84
85 ok(SetTimeZoneInformation(&tziNew) ,
86 "Set Time Zone Information failed with error = %ld.\n", GetLastError());
87
88 // if we got an error the function failed, so there is not much else we can do
89
90 if(GetLastError() != 0xDEADBEEF)
91 {
92 win_skip("SetTimeZoneInformation() is not available, so tests cannot be run.\n");
93 return;
94 }
95
96 // Retrieve and display the newly set time zone information
97
98 dwRet = GetTimeZoneInformation(&tziTest);
99
101 "Get Time Zone Information Returned failed with error = %ld.\n", GetLastError());
102
103 ok(!wcscmp(tziTest.StandardName, tziNew.StandardName),
104 "Standard Time Zone Name = %ls, expected %ls.\n", tziTest.StandardName, tziNew.StandardName);
105
106 ok(!wcscmp(tziTest.DaylightName, tziNew.DaylightName),
107 "Standard Time Zone Name = %ls, expected %ls.\n", tziTest.DaylightName, tziNew.DaylightName);
108
109 /* test RtlQueryTimeZoneInformation returns a TIME_ZONE_INFORMATION structure */
110
111 if (!pRtlQueryTimeZoneInformation)
112 {
113 win_skip("pRtlQueryTimeZoneInformation() fails, so tests cannot be run.\n");
114 return;
115 }
116
117 /* Clear Time Zone Info field */
118 memset(&tzinfo, 0, sizeof(tzinfo));
119
120 /* Read Time Zone Info */
121 status = pRtlQueryTimeZoneInformation(&tzinfo);
122 ok(status == STATUS_SUCCESS, "pRtlQueryTimeZoneInformation failed, got %08lx\n", status);
123
124 /* Check for the Daylight Date Info */
125 ok(tzinfo.DaylightDate.Month == 4, "tzinfo.DaylightDate.wMonth expected '4', got '%d'.\n", tzinfo.DaylightDate.Month);
126 ok(tzinfo.DaylightDate.Day == 2, "tzinfo.DaylightDate.wDay expected '2', got '%d'.\n", tzinfo.DaylightDate.Day);
127 ok(tzinfo.DaylightDate.Weekday == 6, "tzinfo.DaylightDate.wDayOfWeek expected '6', got '%d'.\n", tzinfo.DaylightDate.Weekday);
128 ok(tzinfo.DaylightDate.Year == 0, "tzinfo.DaylightDate.wYear expected '0', got '%d'.\n", tzinfo.DaylightDate.Year);
129
130 /* Check for the Standard Data Info */
131 ok(tzinfo.StandardDate.Month == 11, "tzinfo.StandardDate.wMonth expected '11', got '%d'.\n", tzinfo.StandardDate.Month);
132 ok(tzinfo.StandardDate.Day == 3, "tzinfo.StandardDate.wDay expected '3', got '%d'.\n", tzinfo.StandardDate.Day);
133 ok(tzinfo.StandardDate.Weekday == 5, "tzinfo.StandardDate.wDayOfWeek expected '5', got '%d'.\n", tzinfo.StandardDate.Weekday);
134 ok(tzinfo.StandardDate.Year == 0, "tzinfo.StandardDate.wYear expected '0', got '%d'.\n", tzinfo.StandardDate.Year);
135
136 /* Check for the Bias Info */
137 ok(tzinfo.Bias == 360, "tzinfo.Bias expected '360', got '%ld'.\n", tzinfo.Bias);
138 ok(tzinfo.DaylightBias == -60, "tzinfo.DaylightBias expected '-60', got '%ld'.\n", tzinfo.DaylightBias);
139 ok(tzinfo.StandardBias == 120, "tzinfo.StandardBias expected '120', got '%ld'.\n", tzinfo.StandardBias);
140
141 // Restore the original time zone information and put things back like we found them originally
142 ok(SetTimeZoneInformation(&tziOld),
143 "Set Time Zone Information failed with error = %ld.\n", GetLastError());
144
145}
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI SetTimeZoneInformation(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation)
Definition: timezone.c:316
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TIME_ZONE_ID_UNKNOWN
Definition: rtltypes.h:252
#define TIME_ZONE_ID_STANDARD
Definition: rtltypes.h:253
#define TIME_ZONE_ID_DAYLIGHT
Definition: rtltypes.h:254
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define win_skip
Definition: test.h:160
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wDay
Definition: winbase.h:908
WORD wDayOfWeek
Definition: winbase.h:907
USHORT Weekday
Definition: env_spec_w32.h:718
SYSTEMTIME DaylightDate
Definition: winbase.h:1211
WCHAR DaylightName[32]
Definition: winbase.h:1210
WCHAR StandardName[32]
Definition: winbase.h:1207
SYSTEMTIME StandardDate
Definition: winbase.h:1208
Definition: ps.c:97
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().