Skip to content

Commit

Permalink
private/protocol: Add support for parsing RFC 3339 timestamp without …
Browse files Browse the repository at this point in the history
…trailing Z

Adds support for parsing RFC 3339 timestamp but without the `Z` character, nor UTC offset.

Related to aws/aws-sdk-go-v2#1387
  • Loading branch information
jasdel committed Aug 24, 2021
1 parent ddbcb5b commit cc463f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
### SDK Enhancements

### SDK Bugs
* `private/protocol`: Add support for parsing RFC 3339 timestamp without trailing Z
* Adds support for parsing RFC 3339 timestamp but without the `Z` character, nor UTC offset.
* Related to [aws/aws-sdk-go-v2#1387](https://github.com/aws/aws-sdk-go-v2/issues/1387)
4 changes: 3 additions & 1 deletion private/protocol/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const (
RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"

// RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"
iso8601TimeFormatNoZ = "2006-01-02T15:04:05.999999999"

// This format is used for output time with fractional second precision up to milliseconds
ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
Expand Down Expand Up @@ -82,6 +83,7 @@ func ParseTime(formatName, value string) (time.Time, error) {
case ISO8601TimeFormatName: // Smithy DateTime format
return tryParse(value,
ISO8601TimeFormat,
iso8601TimeFormatNoZ,
time.RFC3339Nano,
time.RFC3339,
)
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 @@ -86,6 +86,11 @@ func TestParseTime(t *testing.T) {
input: "2000-01-02T20:34:56.123Z",
expectedOutput: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC),
},
"ISO8601Test milliseconds, no Z": {
formatName: ISO8601TimeFormatName,
input: "2000-01-02T20:34:56.123",
expectedOutput: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC),
},
"ISO8601Test nanoseconds": {
formatName: ISO8601TimeFormatName,
input: "2000-01-02T20:34:56.123456789Z",
Expand Down

0 comments on commit cc463f0

Please sign in to comment.