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

BUG: NewWithTime uint wrap around causes xid to return wrong time #107

Open
N-o-Z opened this issue Oct 30, 2024 · 0 comments
Open

BUG: NewWithTime uint wrap around causes xid to return wrong time #107

N-o-Z opened this issue Oct 30, 2024 · 0 comments

Comments

@N-o-Z
Copy link

N-o-Z commented Oct 30, 2024

When using NewWithTime, the time object Unix method returns a uint64 which is then cast into a uint32.
Using a future time which exceeds uint32, the xid object returns the wrong timestamp.

Code example:

	nt := time.Unix(4294967296, 0).UTC()
	fmt.Println("time wrap around: ", nt)
	idd := xid.NewWithTime(nt)
	fmt.Println("xid time vs actual: ", idd.Time().Unix(), nt.Unix())

output:

time wrap around:  2106-02-07 06:28:16 +0000 UTC
xid time vs actual:  0 4294967296
0 1970-01-01 00:00:00 +0000 UTC

I feel the need to emphasize that this is not a "future" problem. This is a current issue that impacts code today.
xid needs to respect time object values whether past, present and future and is expected to return the correct object when xid.Time() is called

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

No branches or pull requests

1 participant