Skip to content

Port #838 from release-2.9 to master - #850

Merged
fxamacker merged 1 commit into
masterfrom
fxamacker/port-pr-838-to-master
Oct 2, 2026
Merged

fxamacker merged 1 commit into
masterfrom
fxamacker/port-pr-838-to-master

Conversation

@fxamacker

Copy link
Copy Markdown
Owner

See PR #838 for details.

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.
@fxamacker fxamacker self-assigned this Oct 2, 2026
@fxamacker
fxamacker merged commit dfaeb1b into master Oct 2, 2026
16 checks passed
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 this pull request may close these issues.

2 participants