From b2e6b7ceb8eea0f3e8f934f5e939feb0e7a0be4b Mon Sep 17 00:00:00 2001 From: Sean McGrail Date: Wed, 26 Aug 2020 11:51:29 -0700 Subject: [PATCH 1/4] Limit iso8601 fractional second precision to milliseconds --- private/protocol/timestamp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/private/protocol/timestamp.go b/private/protocol/timestamp.go index 7865c61b097..86dc131ac3a 100644 --- a/private/protocol/timestamp.go +++ b/private/protocol/timestamp.go @@ -27,8 +27,8 @@ const ( // RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z" - // This format is used for output time without seconds precision - ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z" + // This format is used for output time with fractional second precision up milliseconds + ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999Z" ) // IsKnownTimestampFormat returns if the timestamp format name From 34c4027f6d70e4980a438aa896c1a8079d79e90f Mon Sep 17 00:00:00 2001 From: Sean McGrail Date: Wed, 26 Aug 2020 11:56:26 -0700 Subject: [PATCH 2/4] Add CHANGELOG_PENDING.md and correct typo --- CHANGELOG_PENDING.md | 2 ++ private/protocol/timestamp.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 8a1927a39ca..b800678f9f1 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -3,3 +3,5 @@ ### SDK Enhancements ### SDK Bugs +* `private/protocol`: Limit iso8601 fractional second precision to milliseconds ([#3507](https://github.com/aws/aws-sdk-go/pull/3507)) + * Fixes [#3498](https://github.com/aws/aws-sdk-go/issues/3498) diff --git a/private/protocol/timestamp.go b/private/protocol/timestamp.go index 86dc131ac3a..9cdb64eb4d2 100644 --- a/private/protocol/timestamp.go +++ b/private/protocol/timestamp.go @@ -27,7 +27,7 @@ const ( // RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z" - // This format is used for output time with fractional second precision up milliseconds + // This format is used for output time with fractional second precision up to milliseconds ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999Z" ) From 1ef5dd1261c8318ded6294082b6cde879b1b8cc4 Mon Sep 17 00:00:00 2001 From: Sean McGrail Date: Wed, 26 Aug 2020 12:05:37 -0700 Subject: [PATCH 3/4] Add additional test case --- private/protocol/timestamp_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/private/protocol/timestamp_test.go b/private/protocol/timestamp_test.go index bb9331ae7f7..9da63844c37 100644 --- a/private/protocol/timestamp_test.go +++ b/private/protocol/timestamp_test.go @@ -38,6 +38,11 @@ func TestFormatTime(t *testing.T) { expectedOutput: "2000-01-02T20:34:56.123Z", input: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC), }, + "ISO8601Test3": { + formatName: ISO8601TimeFormatName, + expectedOutput: "2000-01-02T20:34:56.123Z", + input: time.Date(2000, time.January, 2, 20, 34, 56, .123456e9, time.UTC), + }, } for name, c := range cases { From a6539900a78b00306be2dc945d3c4c9c09db9ef1 Mon Sep 17 00:00:00 2001 From: Sean McGrail Date: Thu, 27 Aug 2020 16:28:25 -0700 Subject: [PATCH 4/4] Address feedback --- private/protocol/timestamp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/private/protocol/timestamp.go b/private/protocol/timestamp.go index 9cdb64eb4d2..98f4caed91c 100644 --- a/private/protocol/timestamp.go +++ b/private/protocol/timestamp.go @@ -28,7 +28,7 @@ const ( ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z" // This format is used for output time with fractional second precision up to milliseconds - ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999Z" + ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z" ) // IsKnownTimestampFormat returns if the timestamp format name @@ -48,7 +48,7 @@ func IsKnownTimestampFormat(name string) bool { // FormatTime returns a string value of the time. func FormatTime(name string, t time.Time) string { - t = t.UTC() + t = t.UTC().Truncate(time.Millisecond) switch name { case RFC822TimeFormatName: