Open rupertlssmith opened 3 years ago
How can the result from AWS be a Date object? Is that just to cover some case where the sdk code has a Date object internally somehow? I am guessing that AWS services can either use ISO string timestamps, or int unix epoch timestamps.
A parser to be written that will parse ISO or Int, and convert to Inx or Posix.
What about when making requests to AWS? Do different services use different formats, or can all use ISO or int? In which case should I standardize on using int for all?
The possible values of the timestampFormat
field are: iso8601, rfc822 and unixTimestamp, on the shape definition.
Most 'timestamp' shapes seem to no have a format field. Not sure yet if this means they default to a particular format.
This API call takes a timestamp as input:
Shape is a "timestamp" but no "timestampFormat" is specified in the Spec. The actual value seems to be a number with the integer part giving the unix epoch, and milliseconds in the decimal places.
This one takes timestamps as the unix epoch in milliseconds, as an integer:
https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_FilterLogEvents.html
In this case the shape is not "timestamp" but "long".
I think these tests here give some information about what the various timestamp formats should be:
it('converts all header shapes to rfc822', function() {
it('converts all timestamps in JSON protocol to unixTimestamp', function() {
it('converts all timestamps in XML/query protocol to iso8601', function() {
So as u said the aws api's use different time stamp formats, for encoding to wire a set of defaults are used depending on the wire protocol, similarly for decoding if the timestamp format is not present in the response then a default format is used depending on the wire data format.
Taking go sdk as example
For xml it seems to be iso8601 as indicated by
Marshalling (Encoding to xml) -> https://github.com/aws/aws-sdk-go/blob/65c0f3b25668dece412bdfa9e9dbf711942b4e82/private/protocol/xml/xmlutil/build.go#L298
Unmarshalling (Decoding from xml) -> https://github.com/aws/aws-sdk-go/blob/e2d6cb448883e4f4fcc5246650f89bde349041ec/private/protocol/xml/xmlutil/unmarshal.go#L287
For json it seems to be unix time as indicated by
Marshalling (Encoding to json) -> https://github.com/aws/aws-sdk-go/blob/e2d6cb448883e4f4fcc5246650f89bde349041ec/private/protocol/json/jsonutil/build.go#L221
Unmarshalling (Decoding from json) -> https://github.com/aws/aws-sdk-go/blob/e2d6cb448883e4f4fcc5246650f89bde349041ec/private/protocol/json/jsonutil/unmarshal.go#L246
For headers it's rfc822
Marshalling (Encoding to headers) -> https://github.com/aws/aws-sdk-go/blob/e2d6cb448883e4f4fcc5246650f89bde349041ec/private/protocol/rest/build.go#L287
Unmarshalling (Decoding from headers) -> https://github.com/aws/aws-sdk-go/blob/e2d6cb448883e4f4fcc5246650f89bde349041ec/private/protocol/rest/unmarshal.go#L235
iso8601
Timestamp tests:
Based on the cognito service file the DateType is a timestamp which is internally represented as int (Unix secons) for AWSCognito, specifcally the expiration field of identity credentials
As per the the sdk code here, the timestamp can be iso string , date object or a unix timestamp