4#include <winpr/wtypes.h>
5#include <winpr/string.h>
6#include <winpr/timezone.h>
8#if defined(__EMSCRIPTEN__)
10extern void test_timezone_js_set(
const char* tz);
11extern int test_timezone_js_is(
const char* tz);
14static BOOL set_browser_timezone(
const char* tz)
16 test_timezone_js_set(tz);
17 return test_timezone_js_is(tz) != 0;
20static BOOL get_time_zone_key(
char* key,
size_t size)
24 (void)GetDynamicTimeZoneInformation(&tzif);
25 return ConvertWCharNToUtf8(tzif.TimeZoneKeyName, ARRAYSIZE(tzif.TimeZoneKeyName), key, size) >=
29static BOOL test_browser_time_zone(
const char* iana,
const char* expected)
31 char key[128] = WINPR_C_ARRAY_INIT;
33 if (!set_browser_timezone(iana))
35 (void)printf(
"skipping %s, cannot change the time zone here\n", iana);
39 if (!get_time_zone_key(key,
sizeof(key)))
41 (void)fprintf(stderr,
"GetDynamicTimeZoneInformation failed for %s\n", iana);
45 if (strcmp(key, expected) != 0)
47 (void)fprintf(stderr,
"%s: expected time zone key '%s', got '%s'\n", iana, expected, key);
54int TestTimeZoneBrowser(
int argc,
char* argv[])
59#if defined(__EMSCRIPTEN__)
61 char key[128] = WINPR_C_ARRAY_INIT;
62 if (!get_time_zone_key(key,
sizeof(key)) || (strlen(key) == 0))
64 (void)fprintf(stderr,
"no Windows time zone key for the browser time zone\n");
68 if (!test_browser_time_zone(
"Europe/Lisbon",
"GMT Standard Time"))
70 if (!test_browser_time_zone(
"America/New_York",
"Eastern Standard Time"))
72 if (!test_browser_time_zone(
"UTC",
"UTC"))