aboutsummaryrefslogtreecommitdiff
path: root/src/bun_js.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-05-23 00:40:12 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-23 00:40:12 -0700
commit5b38c55c3db018a94505f61cd785f0dd40f442ac (patch)
treeaf522e38ffa9b6c400c500c76de1fdca4ab931db /src/bun_js.zig
parent83e7b9e198b25c7af7905c5dcabe1e325c5a38fb (diff)
downloadbun-5b38c55c3db018a94505f61cd785f0dd40f442ac.tar.gz
bun-5b38c55c3db018a94505f61cd785f0dd40f442ac.tar.zst
bun-5b38c55c3db018a94505f61cd785f0dd40f442ac.zip
Support setting a timezone with `process.env.TZ` and `Bun.env.TZ` (#3018)
* Support setting a timezone via `process.env.TZ` * Implement `setTimeZone` in `bun:jsc` module * [breaking] `bun:test` now defaults to `Etc/UTC` timezone --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun_js.zig')
-rw-r--r--src/bun_js.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bun_js.zig b/src/bun_js.zig
index 5a4eb4f8a..00cb51d20 100644
--- a/src/bun_js.zig
+++ b/src/bun_js.zig
@@ -204,6 +204,13 @@ pub const Run = struct {
vm.is_main_thread = true;
JSC.VirtualMachine.is_main_thread_vm = true;
+ // Allow setting a custom timezone
+ if (vm.bundler.env.get("TZ")) |tz| {
+ if (tz.len > 0) {
+ _ = vm.global.setTimeZone(&JSC.ZigString.init(tz));
+ }
+ }
+
var callback = OpaqueWrap(Run, Run.start);
vm.global.vm().holdAPILock(&run, callback);
}