You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least for the lastModified field of getObject responses from ObjectStorageClient, and likely for any client generating response fields of type Date from HTTP headers, the response field is formatting the parsed header value using the local time zone, despite the formatted value using the Z (UTC) time zone specifier.
The getHours() method of Date instances returns the hours for this date according to local time.
Also, the SDK documentation mentions it should have the Date type, but the field is of type string. The TypeScript declaration also declares it as Date, but the value seems to come verbatim from that formatter, which declares a string return value as seen above.
The following code should reproduce these issues in Deno:
// deno test --allow-all repro.tsimporttype{HttpClient,HttpRequest}from"npm:oci-common";import"npm:bunyan";import{ObjectStorageClient}from"npm:oci-objectstorage";import{assertEquals}from"https://deno.land/[email protected]/assert/mod.ts";classTestHttpClientimplementsHttpClient{send(_req: HttpRequest): Promise<Response>{returnPromise.resolve(newResponse("test-data",{headers: {"last-modified": "Tue, 15 Nov 1994 12:45:26 GMT"},}),);}}Deno.test("lastModified in getObject response",async()=>{consthttpClient=newTestHttpClient();constclient=newObjectStorageClient({ httpClient });try{constresp=awaitclient.getObject({bucketName: "test-bucket",objectName: "test-object",namespaceName: "test-namespace",});// The field is declared as Date, but it is actually a stringconstlastModified=(resp.lastModifiedasunknown)asstring;assertEquals(lastModified,"1994-11-15T12:45:26Z");}finally{client.shutdownCircuitBreaker();}});
The text was updated successfully, but these errors were encountered:
Hi @ricardo-kagawa, thanks for highlighting this issue. I think you're right on both accounts. Looks like we should be using getUTCHours() instead of getHours() (as well as minutes, seconds, etc.). Additionally we should be returning a Date from the formatter, as it looks like the other SDKs return some sort of Date/Time object, and not a string. This should be a relatively easy, I will work with the team to implement it.
At least for the
lastModified
field ofgetObject
responses fromObjectStorageClient
, and likely for any client generating response fields of typeDate
from HTTP headers, the response field is formatting the parsed header value using the local time zone, despite the formatted value using theZ
(UTC) time zone specifier.oci-typescript-sdk/lib/common/lib/helper.ts
Line 299 in 52a6526
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours
Also, the SDK documentation mentions it should have the
Date
type, but the field is of typestring
. The TypeScript declaration also declares it asDate
, but the value seems to come verbatim from that formatter, which declares astring
return value as seen above.The following code should reproduce these issues in Deno:
The text was updated successfully, but these errors were encountered: