Preserve sub-second precision when serializing timestamps - #3353
Open
jonathan343 wants to merge 1 commit into
Open
jonathan343 wants to merge 1 commit into
jonathan343 wants to merge 1 commit into
Conversation
Serialize unixTimestamp and iso8601 request timestamps with the sub-second precision the caller provided instead of truncating to whole seconds. Whole-second values are unchanged; rfc822 remains whole seconds per spec. Add TimestampShape::formatAsString for string-bound locations (query, XML, REST headers/querystring/URI) so float epoch values are not truncated by PHP's `precision` ini setting when cast to string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The PHP SDK serializes request timestamps by calling
DateTimeInterface::getTimestamp()(orstrtotime()for strings), which returns whole seconds and drops any sub-second precision the caller provided. This affects theunixTimestampformat used byjson,rest-json, andsmithy-rpc-v2-cborbodies, and theiso8601format used byquery,rest-xml, and REST querystring/URI bindings.rfc822(HTTP-date) only supports whole seconds and is unchanged.This PR preserves the caller's sub-second precision for
unixTimestampandiso8601. Whole-second timestamps serialize exactly as before. It is the PHP counterpart to boto/botocore#3796 and fixes the PHP equivalent of boto/botocore#3255.Testing
Added unit tests for
TimestampShape::format()/formatAsString()and end-to-end serializer tests forjson,query,rest-xml, andrest-jsonbindings. Protocol compliance tests pass. PHPStan reports no errors on the touched files.Reproduced the scenario from boto/botocore#3255 with
KinesisVideoArchivedMedia::listFragments, capturing the serialized body with a mock handler:Before (
master):After:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.