Skip to content

Round pre-epoch timestamps consistently to microseconds - #914

Merged
staticlibs merged 1 commit into
duckdb:mainfrom
hutiefang76:frank/newten-dd-negative-micros-20261010-01a11186
Oct 10, 2026
Merged

staticlibs merged 1 commit into
duckdb:mainfrom
hutiefang76:frank/newten-dd-negative-micros-20261010-01a11186

Conversation

@hutiefang76

Copy link
Copy Markdown
Contributor

Converting a timestamp before 1970 through ChronoUnit.MICROS truncates the epoch interval toward zero: 1969-12-31 23:59:59.987654321 becomes .987655. The fix derives microseconds from the UTC epoch second and fractional nanoseconds, making sub-microsecond truncation consistent on both sides of the epoch. Constructors and JDBC binding share the conversion; existing pre-epoch offset-time coverage is corrected accordingly.

Validation on macOS arm64: compiled all Java production and test sources against the existing JNI artifact; ran TestTimestamp (26 tests). New regressions fail against the original Java implementation and pass with this patch. The full official clang-format 11 check passes. Full native and multi-platform CI remain to be run.

AI assistance was used for implementation and source review.

Signed-off-by: hutiefang76 <137664623+hutiefang76@users.noreply.github.com>

@staticlibs staticlibs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Looks good to me.

@staticlibs
staticlibs merged commit 913824b into duckdb:main Oct 10, 2026
31 of 32 checks passed
staticlibs pushed a commit that referenced this pull request Oct 10, 2026
This is a backport of the PR #914 to `v2.0-cyanoptera` branch.
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.

2 participants