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

Is this expected? time.Now().Before(time.Unix(2<<62 - 1, 0)) = false #39477

Closed
keenangebze opened this issue Jun 9, 2020 · 2 comments
Closed

Comments

@keenangebze
Copy link

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

$ go version
go version go1.12.4 linux/amd64

Does this issue reproduce with the latest release?

Not yet tested

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nakama/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nakama/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/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-build340274852=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
        "fmt"
        "time"
)

func main() {
        today := time.Now()
        future := time.Unix(2<<62 - 1, 0)

        fmt.Println(today, future)
        fmt.Println(today.Before(future))
}

What did you expect to see?

2020-06-09 21:40:19.250234793 +0700 WIB m=+0.000164020 292277026596-12-04 22:30:07 +0700 WIB
true

What did you see instead?

2020-06-09 21:40:19.250234793 +0700 WIB m=+0.000164020 292277026596-12-04 22:30:07 +0700 WIB
false
@seankhliao
Copy link
Member

https://golang.org/pkg/time/#Unix

Not all sec values have a corresponding time value. One such value is 1<<63-1 (the largest int64 value).

@ALTree
Copy link
Member

ALTree commented Jun 9, 2020

What @seankhliao said. Note that 2<<62 == 1<<63. Closing here, since this is working as documented.

@ALTree ALTree closed this as completed Jun 9, 2020
@golang golang locked and limited conversation to collaborators Jun 9, 2021
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