Remove the old mono timezone icall implementation from driver.c (#44171)
authorLarry Ewing <lewing@microsoft.com>
Tue, 3 Nov 2020 23:37:30 +0000 (17:37 -0600)
committerGitHub <noreply@github.com>
Tue, 3 Nov 2020 23:37:30 +0000 (17:37 -0600)
* Remove unused on netcore icall and set TZ in the startup js

src/mono/wasm/runtime/driver.c
src/mono/wasm/runtime/library_mono.js

index 3bf8387..cda362c 100644 (file)
@@ -928,27 +928,3 @@ mono_wasm_enable_on_demand_gc (int enable)
 {
        mono_wasm_enable_gc = enable ? 1 : 0;
 }
-
-// Returns the local timezone default is UTC.
-EM_JS(size_t, mono_wasm_timezone_get_local_name, (),
-{
-       var res = "UTC";
-       try {
-               res = Intl.DateTimeFormat().resolvedOptions().timeZone;
-       } catch(e) {}
-
-       var buff = Module._malloc((res.length + 1) * 2);
-       stringToUTF16 (res, buff, (res.length + 1) * 2);
-       return buff;
-})
-
-void
-mono_timezone_get_local_name (MonoString **result)
-{
-       // WASM returns back an int pointer to a string UTF16 buffer.
-       // We then cast to `mono_unichar2*`.  Returning `mono_unichar2*` from the JavaScript call will
-       // result in cast warnings from the compiler.
-       mono_unichar2 *tzd_local_name = (mono_unichar2*)mono_wasm_timezone_get_local_name ();
-       *result = mono_string_from_utf16 (tzd_local_name);
-       free (tzd_local_name);
-}
index 2afcde3..0f3cb96 100644 (file)
@@ -1653,6 +1653,11 @@ var MonoSupportLib = {
                                load_runtime ("unused", args.debug_level);
                        }
 
+                       let tz;
+                       try {
+                               tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
+                       } catch {}
+                       MONO.mono_wasm_setenv ("TZ", tz || "UTC");
                        MONO.mono_wasm_runtime_ready ();
                        args.loaded_cb ();
                },