Skip to content

Correct timestamp normalization at integer boundaries - #1458

Open
RanaPriyansh wants to merge 1 commit into
tokio-rs:masterfrom
RanaPriyansh:fix/timestamp-normalization-1412
Open

RanaPriyansh wants to merge 1 commit into
tokio-rs:masterfrom
RanaPriyansh:fix/timestamp-normalization-1412

Conversation

@RanaPriyansh

Copy link
Copy Markdown

Fixes #1412.

Timestamp::try_normalize() can accept overflowing timestamps and reject valid values that normalize exactly to an integer boundary. Use checked arithmetic for the whole-second adjustment and Euclidean remainder for nanoseconds. Preserve the original value on failure and leave saturating normalization unchanged.

Regression tests include integer boundaries and an independent integer oracle. Local prost-types library tests passed with default features, no default features, and all features. Focused debug and release checks, strict package documentation, and workspace formatting passed on Rust 1.97.

Strict package Clippy fails on an existing question_mark diagnostic in datetime.rs. Full workspace and platform CI have not run locally.

Prepared with AI assistance.

@RanaPriyansh
RanaPriyansh force-pushed the fix/timestamp-normalization-1412 branch from 1ea0531 to dfef52d Compare September 24, 2026 09:45
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.

Timestamp::try_normalize returns Ok after lossy clamping at i64::MIN/i64::MAX

1 participant