diff --git a/CHANGELOG.md b/CHANGELOG.md index 1335fcd02..09f64fbd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Release pending + +### Smithy Go Module + +* `time`: Add support for parsing additional DateTime timestamp format ([#324](https://github.com/aws/smithy-go/pull/324)) + * Adds support for parsing DateTime timestamp formatted time similar to RFC 3339, but without the `Z` character, nor UTC offset. + * Fixes [#1387](https://github.com/aws/aws-sdk-go-v2/issues/1387) + # Release v1.7.0 ### Smithy Go Module diff --git a/time/time.go b/time/time.go index ad4087cf0..a9634ba34 100644 --- a/time/time.go +++ b/time/time.go @@ -10,8 +10,9 @@ import ( const ( // dateTimeFormat is a IMF-fixdate formatted RFC3339 section 5.6 - dateTimeFormatInput = "2006-01-02T15:04:05.999999999Z" - dateTimeFormatOutput = "2006-01-02T15:04:05.999Z" + dateTimeFormatInput = "2006-01-02T15:04:05.999999999Z" + dateTimeFormatInputNoZ = "2006-01-02T15:04:05.999999999" + dateTimeFormatOutput = "2006-01-02T15:04:05.999Z" // httpDateFormat is a date time defined by RFC 7231#section-7.1.1.1 // IMF-fixdate with no UTC offset. @@ -36,6 +37,7 @@ func FormatDateTime(value time.Time) string { func ParseDateTime(value string) (time.Time, error) { return tryParse(value, dateTimeFormatInput, + dateTimeFormatInputNoZ, time.RFC3339Nano, time.RFC3339, ) diff --git a/time/time_test.go b/time/time_test.go index 1e5ac345d..542e9ea55 100644 --- a/time/time_test.go +++ b/time/time_test.go @@ -19,6 +19,12 @@ func TestDateTime(t *testing.T) { time.UTC), SymmetricString: true, }, + "no offset, no Z": { + TimeString: "1985-04-12T23:20:50.524", + TimeValue: time.Date(1985, 4, 12, 23, 20, 50, int(524*time.Millisecond), + time.UTC), + SymmetricString: false, + }, "with negative offset": { TimeString: "1985-04-12T23:20:50.52-07:00", TimeValue: time.Date(1985, 4, 12, 23, 20, 50, int(520*time.Millisecond),