diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-12-05 16:52:12 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-05 22:24:50 +0000 |
commit | 91b3a3bb58d7d1327b4e22dc02364fd4ebb7a48b (patch) | |
tree | cba11c9bf2ed7d91a862b4cbf21696a0fea38e7e /Meta/Lagom/Wasm | |
parent | 14524ad0193cf72d7ac78245fbccb2643e4da1d0 (diff) | |
download | serenity-91b3a3bb58d7d1327b4e22dc02364fd4ebb7a48b.zip |
Meta: Initialize the WASM JS REPL with a known time zone
The runtime environment of the WASM REPL does not have time zone
information; the file system is virtual (does not have /etc/localtime),
and the TZ environment variable is not set. This causes LibTimeZone to
always fall back to UTC.
Instead, we can get the time zone from the user's browser before we
enter this limited environment. The REPL website will pass the time zone
into the WASM REPL.
Diffstat (limited to 'Meta/Lagom/Wasm')
-rw-r--r-- | Meta/Lagom/Wasm/js_repl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp index 76674d3af0..cb798241bf 100644 --- a/Meta/Lagom/Wasm/js_repl.cpp +++ b/Meta/Lagom/Wasm/js_repl.cpp @@ -29,6 +29,7 @@ #include <fcntl.h> #include <signal.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #ifndef AK_OS_EMSCRIPTEN @@ -349,8 +350,11 @@ private: int m_group_stack_depth { 0 }; }; -extern "C" int initialize_repl() +extern "C" int initialize_repl(char const* time_zone) { + if (time_zone) + setenv("TZ", time_zone, 1); + g_vm = JS::VM::create(); g_vm->enable_default_host_import_module_dynamically_hook(); |