From 2bb3f6265fe3cd348ccdb58b7844d77abd9628dd Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Thu, 14 Sep 2023 18:25:12 +0100 Subject: [PATCH] Idea how to set host tz in the container --- .devcontainer/devcontainer.json | 6 ++++++ .devcontainer/getHostTimeZone.ps1 | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 .devcontainer/getHostTimeZone.ps1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1341b2c8..87492cb8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,6 +22,12 @@ 3000, 3333 ], + // "initializeCommand" to get host timezone + "initializeCommand": "powershell -File .\\.devcontainer\\getHostTimeZone.ps1 || echo ''", + // set container timezone + "remoteEnv": { + "TZ": "${localEnv:TZ}" + }, // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "sh .devcontainer/post-create.sh", // Configure tool-specific properties. diff --git a/.devcontainer/getHostTimeZone.ps1 b/.devcontainer/getHostTimeZone.ps1 new file mode 100644 index 00000000..d02dc684 --- /dev/null +++ b/.devcontainer/getHostTimeZone.ps1 @@ -0,0 +1,4 @@ +$env:TZ = [Windows.Globalization.Calendar,Windows.Globalization,ContentType=WindowsRuntime]::New().GetTimeZone() +[Environment]::SetEnvironmentVariable('TZ', "$env:TZ", 'Process') +[Environment]::SetEnvironmentVariable('TZ', "$env:TZ", 'User') +Write-Host "Host timezone: $env:TZ" \ No newline at end of file