Skip to content

Commit

Permalink
Limit iso8601 fractional second precision to milliseconds (#3507)
Browse files Browse the repository at this point in the history
  • Loading branch information
skmcgrail authored Aug 28, 2020
1 parent f324f9f commit 9ff9264
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions private/protocol/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 without seconds precision
// This format is used for output time with fractional second precision up to milliseconds
ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
)

Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions private/protocol/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9ff9264

Please sign in to comment.