Skip to content

Port #837 from release-2.9 to master - #846

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

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

Conversation

@fxamacker

@fxamacker fxamacker commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

See PR #837 for details.

Not affected: user apps that don't use the TimeUnixMicro option,
or user apps that use the TimeUnixMicro option to encode time.Time
from 1677-09-21T00:12:44Z to 2262-04-11T23:47:15.999999Z.

This commit encodes time.Time with the TimeUnixMicro option as
float64(Time.Unix()) + float64(Time.Nanosecond())/1e9 when the Unix
seconds are outside the range where Time.UnixNano is defined for
any nanosecond fraction. Times within the range are still encoded
in the same way to keep encoded data unchanged from prior versions.

Previously, encoding a time before 1677-09-21T00:12:43.145225Z or
after 2262-04-11T23:47:16.854775Z with the TimeUnixMicro option
produced data that decodes to a different time because
Time.UnixNano overflows int64. For example, 9999-12-31T23:59:59Z
decoded as 1816-03-30T05:56:07Z.

Also, in less than one second at each end of that range (on
1677-09-21 and on 2262-04-11), some times now encode to a value
nearer to the exact time: 1677-09-21T00:12:43.145225Z to
00:12:43.999999Z, and 2262-04-11T23:47:16Z to 23:47:16.854775Z.
@fxamacker fxamacker self-assigned this Oct 1, 2026
@fxamacker
fxamacker changed the base branch from fxamacker/port-pr-833-to-master to master October 2, 2026 05:17
@fxamacker
fxamacker merged commit 1cf87e8 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