Port #838 from release-2.9 to master - #850
Merged
Merged
Conversation
Not affected: user apps that encode time.Time with TimeUnix (the default), TimeUnixMicro, or TimeUnixDynamic, or that don't encode times about 292 billion years before 1970. Go's standard library doesn't fully support time values in a ~257-year range about 292 billion years before 1970. Some Go standard library functions still work but some will return wrong results for time.Time inside that range. Go's time formatting writes a wrong date for a local time before the earliest time Go supports: the year is about 292 billion years after 1970 instead of before. For example, Go formats time.Unix(math.MinInt64, 0).UTC() as "292277026596-12-04T15:30:08Z". Previously, encoding CBOR time as a text string (instead of integer or float) didn't check if Go returned an incorrect string for time.Time values in the unsupported ~257-year range over 292 billion years ago. This commit returns UnsupportedValueError when the formatted year returned by the Go standard library is wrong. This commit doesn't change encoding of any other time value with a time zone offset up to 168 hours (one week). For perspective, this only affects dates about 292 billion years ago and the estimated age of the universe is less than 14 billion years.
x448
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See PR #838 for details.