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: Parse is incorrect on some platforms #18373

Closed
deafgoat opened this issue Dec 19, 2016 · 3 comments
Closed

time: Parse is incorrect on some platforms #18373

deafgoat opened this issue Dec 19, 2016 · 3 comments

Comments

@deafgoat
Copy link
Contributor

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

OS X: go version go1.6 darwin/amd64
PowerPC (PPC): go version go1.4.2 gccgo (GCC) 5.4.0 linux/ppc64le
s390x: go version go1.4.2 gccgo (GCC) 5.4.0 linux/s390x

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

OS X:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gopath"
GORACE=""
GOROOT="/usr/local/opt/go/libexec"
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

PPC:

GOARCH="ppc64le"
GOBIN=""
GOCHAR="9"
GOEXE=""
GOHOSTARCH="ppc64le"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/opt/toolchain"
GOTOOLDIR="/opt/toolchain/libexec/gcc/ppc64le-linux/5.4.0"
CC="/opt/toolchain/bin/gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0"
CXX="/opt/toolchain/bin/g++"
CGO_ENABLED="1"

s390x:

GOARCH="s390x"
GOBIN=""
GOCHAR=""
GOEXE=""
GOHOSTARCH="s390x"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/opt/toolchain/"
GOTOOLDIR="/opt/toolchain/libexec/gcc/s390x-linux/5.4.0"
CC="/opt/toolchain/bin/gcc"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0"
CXX="/opt/toolchain/bin/g++"
CGO_ENABLED="1"

What did you do?

Ran this program:

package main

import (
	"fmt"
	"time"
)

func main() {
	value := "2000-09-31 00:00:00.000231"
	format := "2006-01-02 15:04:05.000000"
	v, err := time.Parse(format, value)
	if err == nil {
		fmt.Printf("parsed: %v\n", v.String())
	} else {
		fmt.Printf("not parsed: %v\n", err)
	}
}

Play at https://play.golang.org/p/PZbFKkwPKd

*Note that the time value - 2000-09-31 00:00:00.000231 - is invalid as the last day in September, 2000 is 30 and not 31.

What did you expect to see?

not parsed: parsing time "2000-09-31 00:00:00.000231": day out of range

What did you see instead?

On OS X, worked as expected but on PPC and s390x, saw this instead:

parsed: 2000-10-01 00:00:00.000231 +0000 UTC
@dominikh
Copy link
Member

Your PPC and s390x run Go 1.4.2, while your OS X runs Go 1.6. That's not a useful comparison, and more than likely this is a bug that was fixed somewhere between 1.4 and 1.6.

@deafgoat
Copy link
Contributor Author

You're right, a fix might already have been made but I checked through the issues and didn't find anything related so I assumed it isn't yet fixed.

I don't have access to a more recent tool chain for PPC and s390x on my test boxes so I couldn't empirically check if this is already fixed in any newer versions.

@bradfitz
Copy link
Contributor

5ef8991 fixed #7268 a year ago. That sounds like it would've been in Go 1.6.

@golang golang locked and limited conversation to collaborators Dec 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants