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

Integer overflow in time.Time comparison #1581

Closed
myxo opened this issue Mar 29, 2024 · 0 comments · Fixed by #1582
Closed

Integer overflow in time.Time comparison #1581

myxo opened this issue Mar 29, 2024 · 0 comments · Fixed by #1582
Labels

Comments

@myxo
Copy link
Contributor

myxo commented Mar 29, 2024

Description

time.Time comparison rely on https://pkg.go.dev/time#Time.UnixNano, but documentation explicitly said, that it has undefined behavior is data is bigger than year 2262 (since it not fit in int64)

Step To Reproduce

func TestTime(t *testing.T) {
	require.Less(t, time.Now(), time.Date(2263, 0, 0, 0, 0, 0, 0, time.Local))
}

Error: "2024-03-29 08:20:14.8719425 +0300 MSK m=+0.001135586" is not less than "2262-11-30 00:00:00 +0300 MSK"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant