Skip to content

time: date conversion does not work when cross compiling for Linux #19123

@skaggmannen

Description

@skaggmannen

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.3 windows/amd64

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Projects\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

What did you do?

Conversion to UTC does not seem to work as expected on different platforms. The following program does not give the expected output when compiled for Linux:

package main

import (
	"fmt"
	"time"
)

func main() {
	if now, err := time.Parse(time.RFC850, "Thursday, 16-Feb-17 14:48:58 CET"); err != nil {
		fmt.Print(err)
	} else {
		fmt.Println("now: ", now)
		fmt.Println("now (utc): ", now.UTC())
	}
}

The output when building for Windows (GOOS=windows) is this:

now:  2017-02-16 14:48:58 +0100 CET
now (utc):  2017-02-16 13:48:58 +0000 UTC

But when compiling for Linux (GOOS=linux) I get this output instead:

now:  2017-02-16 14:48:58 +0000 CET
now (utc):  2017-02-16 14:48:58 +0000 UTC

I tested the Linux binary in Ubuntu Bash for Windows, and on a Raspberry PI (built with GOARCH=arm). The result is the same on both platforms.

I've also tested it in the Golang Playground and it seems to be wrong there as well:

https://play.golang.org/p/kFvAJEx7dw

What did you expect to see?

now:  2017-02-16 14:48:58 +0100 CET
now (utc):  2017-02-16 13:48:58 +0000 UTC

What did you see instead?

now:  2017-02-16 14:48:58 +0000 CET
now (utc):  2017-02-16 14:48:58 +0000 UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions