Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 9ff9264

Browse files
authored
Limit iso8601 fractional second precision to milliseconds (#3507)
1 parent f324f9f commit 9ff9264

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG_PENDING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
### SDK Enhancements
44

55
### SDK Bugs
6+
* `private/protocol`: Limit iso8601 fractional second precision to milliseconds ([#3507](https://github.com/aws/aws-sdk-go/pull/3507))
7+
* Fixes [#3498](https://github.com/aws/aws-sdk-go/issues/3498)

private/protocol/timestamp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
// RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z
2828
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"
2929

30-
// This format is used for output time without seconds precision
30+
// This format is used for output time with fractional second precision up to milliseconds
3131
ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
3232
)
3333

@@ -48,7 +48,7 @@ func IsKnownTimestampFormat(name string) bool {
4848

4949
// FormatTime returns a string value of the time.
5050
func FormatTime(name string, t time.Time) string {
51-
t = t.UTC()
51+
t = t.UTC().Truncate(time.Millisecond)
5252

5353
switch name {
5454
case RFC822TimeFormatName:

private/protocol/timestamp_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func TestFormatTime(t *testing.T) {
3838
expectedOutput: "2000-01-02T20:34:56.123Z",
3939
input: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC),
4040
},
41+
"ISO8601Test3": {
42+
formatName: ISO8601TimeFormatName,
43+
expectedOutput: "2000-01-02T20:34:56.123Z",
44+
input: time.Date(2000, time.January, 2, 20, 34, 56, .123456e9, time.UTC),
45+
},
4146
}
4247

4348
for name, c := range cases {

0 commit comments

Comments
 (0)