Skip to content

time.Now().String() should work #32

Closed
@hajimehoshi

Description

@hajimehoshi

Trying to convert a time.Time object to a string might not work. It is because this seems to need the access to a file where zones are defined if the Time includes a locale. As far as I know, a Time object with UTC (like a Time created by time.Parse()) doesn't cause problems. For example, on my locale machine:

package main

import (
        "time"
)

func main() {
        print(time.Now().String())
}

can be compiled, but the JavaScript file results in:

Uncaught Error: syscalls not available test.js:1145
go$panic test.js:1145
go$packages.syscall.syscall syscall_unix.go:33
go$packages.syscall.go$pkg.Syscall syscall_unix.go:41
go$packages.syscall.go$pkg.Open zsyscall_darwin_amd64.go:833
go$packages.time.readFile sys_unix.go:23
go$packages.time.loadZoneFile zoneinfo_read.go:206
go$packages.time.initLocal zoneinfo_unix.go:59
go$packages.sync.Once.Ptr.Do once.go:40
go$packages.time.Location.Ptr.get zoneinfo.go:69
go$packages.time.Time.Ptr.locabs time.go:272
go$packages.time.Time.Ptr.Format format.go:415
go$packages.time.Time.Ptr.String format.go:400
go$packages.main.go$pkg.main test.go:9
(anonymous function) test.go:9
(anonymous function)

I wonder if I could use Time object without accessing any files. As JavaScript's Time knows the local locale, time.Now().String() should be able to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions