Skip to content

time: Parse is incorrect on some platforms #18373

@deafgoat

Description

@deafgoat

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

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