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: time.Since returns a positive value for a max int64 unix time #53514

Closed
adirizka7 opened this issue Jun 23, 2022 · 2 comments
Closed

time: time.Since returns a positive value for a max int64 unix time #53514

adirizka7 opened this issue Jun 23, 2022 · 2 comments

Comments

@adirizka7
Copy link

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

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

Haven't tested.

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

go env Output
$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN="/Users/user/go/bin"
GOCACHE="/Users/user/Library/Caches/go-build"
GOENV="/Users/user/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/user/go/pkg/mod"
GONOPROXY="github.com/company/*"
GONOSUMDB="github.com/company/*"
GOOS="darwin"
GOPATH="/Users/user/go"
GOPRIVATE="github.com/company/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.18/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/43/tj8j9j210w90_qk38fv70gs80000gp/T/go-build119987376=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I ran this.

package main

import (
	"fmt"
	"math"
	"time"
)

func main() {
	updatedAt := time.Unix(math.MaxInt64, 0)
	fmt.Println(updatedAt)
        fmt.Println(time.Since(updatedAt))

	updatedAt = time.Unix(922337203685477580, 0)
	fmt.Println(time.Since(updatedAt))
}

What did you expect to see?

I expect to see the output of time.Since(maxInt64) as a negative value.

What did you see instead?

It returns a positive value.

292277026596-12-04 15:30:07 +0000 UTC
2562047h47m16.854775807s
-2562047h47m16.854775808s
@ZekeLu
Copy link
Contributor

ZekeLu commented Jun 23, 2022

Duplicate of #6210 and #10906.

@seankhliao
Copy link
Member

Duplicate of #10906

@seankhliao seankhliao marked this as a duplicate of #10906 Jun 23, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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