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

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

keenangebze opened this issue Jun 9, 2020 · 2 comments

Comments

@keenangebze
Copy link

@keenangebze keenangebze commented Jun 9, 2020

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
Contributor

@seankhliao seankhliao commented Jun 9, 2020

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 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 Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.