Skip to content

fix: keep sub-second precision and long durations of protobuf times - #864

Merged
xepozz merged 1 commit into
masterfrom
fix/protobuf-time-precision
Nov 29, 2026
Merged

xepozz merged 1 commit into
masterfrom
fix/protobuf-time-precision

Conversation

@xepozz

@xepozz xepozz commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

What was changed

Protobuf Timestamp/Duration conversions keep sub-second precision and long durations (schedule backfill, matching times, describe() → update()). Schedule enums marshal as values.

Why?

Sub-second parts were truncated, and durations of one month or longer came back as months, which changed them on update().

Checklist

  1. Closes: follow-up to fix(client): keep leading zeros when converting protobuf timestamps #862

  2. How was this tested: new unit tests; Unit, Acceptance and schedule acceptance suites pass.

  3. Any docs updates needed? No.

@xepozz
xepozz requested review from a team, roxblnfk and wolfy-j as code owners November 29, 2026 12:19
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T12:21:38.643955Z 07b531c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@xepozz
xepozz force-pushed the fix/protobuf-time-precision branch from 07b531c to d4494a7 Compare November 29, 2026 12:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07b531c7d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Internal/Support/DateInterval.php Outdated
Comment on lines +201 to +204
$nanos = (int) \round($seconds * self::NANOSECONDS_PER_SECOND_FLOAT);

return (new Duration())
->setSeconds(\intdiv($nanos, self::NANOSECONDS_PER_SECOND))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Split whole seconds before converting the fraction to nanoseconds

For float durations above roughly 9.22 billion seconds on 64-bit PHP, multiplying the entire duration by one billion exceeds PHP_INT_MAX; casting the result then corrupts the seconds as well as the fractional part. For example, 10000000000.5 now produces seconds = -8446744073, turning a positive duration into a negative one. Both duration marshallers now use this helper, so this introduces whole-second corruption for long durations that previously retained their seconds. Extract the whole seconds first and scale only the fractional remainder, accounting for rounding that carries into the next second.

Useful? React with 👍 / 👎.

Convert Timestamp/Duration with protobuf helpers and DateInterval::parse.
Keep sub-second times in schedule backfill and matching times.
Share float seconds to Duration conversion in DateInterval::secondsToDuration.
Marshal schedule enums as values with EnumValueType.
@xepozz
xepozz force-pushed the fix/protobuf-time-precision branch from d4494a7 to 9e2e4e9 Compare November 29, 2026 12:36
@xepozz
xepozz merged commit 1d2cf9d into master Nov 29, 2026
348 of 350 checks passed
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