Skip to content

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

Open
@N-o-Z

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions