Skip to content

fix(model): floor negative Unix timestamps to seconds - #990

Open
jakezwang wants to merge 1 commit into
prometheus:mainfrom
jakezwang:fix/negative-unix-seconds
Open

jakezwang wants to merge 1 commit into
prometheus:mainfrom
jakezwang:fix/negative-unix-seconds

Conversation

@jakezwang

Copy link
Copy Markdown

model.Time(-1).Unix() returns 0, while the same instant converted with Time().Unix() returns -1. Integer division truncates negative fractional seconds toward zero.

Reuse the existing time.Time conversion so Unix seconds round down consistently. Tests cover both sides of the epoch, exact seconds, and the earliest/latest representable millisecond timestamps.

Validation: the four negative fractional cases fail before the fix. make test passes on Go 1.25.13 and 1.26.6, including the full race suite and pinned golangci-lint. License/style and asset checks pass. Both modules declare Go 1.25.0; the shell version-check script requires readarray, unavailable in the local macOS Bash.

@roidelapluie

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.

1 participant