Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: location data always falls back to UTC in js/wasm #28265

Closed
eternal-flame-AD opened this issue Oct 18, 2018 · 3 comments
Closed

time: location data always falls back to UTC in js/wasm #28265

eternal-flame-AD opened this issue Oct 18, 2018 · 3 comments
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@eternal-flame-AD
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ef/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ef/code/go/"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build929309457=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Build and run the following snippet both in linux/amd64(local architecture) and wasm/js

package main

import (
	"fmt"
	"time"
)

func main() {
	fmt.Println(time.Now().Location())
}

What did you expect to see?

The results should be consisitent with the following javascript code, which should return the OS timezone info:

console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)

What did you see instead?

On native architecture(linux/amd64):

Asia/Shanghai

On browser javascript:

Asia/Shanghai

On wasm:

UTC
@agnivade
Copy link
Contributor

zoneinfo_unix.go seems to contain js,wasm. Hence in a browser environment, it falls back to UTC. I think it should be possible to have a zoneinfo_js.go and call into wasm_exec.js to get the browser/node timezone.

@agnivade agnivade changed the title time: Unable to acquire timezone data in wasm/js time: location data always falls back to UTC in js/wasm Oct 18, 2018
@agnivade agnivade added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues labels Oct 18, 2018
@agnivade agnivade added this to the Go1.12 milestone Oct 18, 2018
@eternal-flame-AD
Copy link
Author

Yep, I think it require at least a bit of refactoring on the time package as the current infrastructure of the time package is not designed to handle handle timezone operations using syscall

@agnivade agnivade self-assigned this Oct 18, 2018
@gopherbot
Copy link

Change https://golang.org/cl/143577 mentions this issue: time: return correct zone info for wasm

@golang golang locked and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants