Skip to content

docs(NewWithTime): note 4-byte timestamp can't hold post-2106 times#116

Open
c-tonneslan wants to merge 1 commit into
rs:masterfrom
c-tonneslan:docs/document-time-limit
Open

docs(NewWithTime): note 4-byte timestamp can't hold post-2106 times#116
c-tonneslan wants to merge 1 commit into
rs:masterfrom
c-tonneslan:docs/document-time-limit

Conversation

@c-tonneslan

Copy link
Copy Markdown

For #107.

The xid format reserves 4 bytes for the timestamp, so any time whose Unix seconds don't fit in `uint32` (anything before 1970 or after 2106-02-07 06:28:15 UTC) silently wraps when encoded. The current NewWithTime godoc doesn't mention this, so callers who feed arbitrary user-supplied times can quietly end up with IDs whose `Time()` returns 1970.

Documents the bounds so callers know to clamp/reject themselves. Not changing behaviour, since the encoding format is fixed.

The xid format reserves 4 bytes for the timestamp, so any time whose
Unix seconds don't fit in a uint32 (anything before 1970 or after
2106-02-07 06:28:15 UTC) silently wraps when encoded. The current
NewWithTime godoc doesn't mention this, so callers who feed in
arbitrary user-supplied times can quietly end up with IDs whose
Time() returns nonsense.

Document the bounds so callers know to clamp/reject themselves.

For rs#107

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
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

Successfully merging this pull request may close these issues.

1 participant