diff --git a/.changeset/lucky-hats-doubt.md b/.changeset/lucky-hats-doubt.md new file mode 100644 index 00000000000..6605a1d93c9 --- /dev/null +++ b/.changeset/lucky-hats-doubt.md @@ -0,0 +1,5 @@ +--- +"@smithy/smithy-client": patch +--- + +truncate timestamp ending in 000 milliseconds diff --git a/packages/smithy-client/src/ser-utils.spec.ts b/packages/smithy-client/src/ser-utils.spec.ts index b0529abe03e..98f6db32a1e 100644 --- a/packages/smithy-client/src/ser-utils.spec.ts +++ b/packages/smithy-client/src/ser-utils.spec.ts @@ -14,10 +14,10 @@ describe("serializeFloat", () => { }); describe("serializeDateTime", () => { - it("should not truncate at the top of the second", () => { + it("should truncate at the top of the second", () => { const date = new Date(1716476757761); date.setMilliseconds(0); - expect(serializeDateTime(date)).toEqual("2024-05-23T15:05:57.000Z"); + expect(serializeDateTime(date)).toEqual("2024-05-23T15:05:57Z"); }); it("should not truncate in general", () => { diff --git a/packages/smithy-client/src/ser-utils.ts b/packages/smithy-client/src/ser-utils.ts index 58f160fe7af..2397f7809d8 100644 --- a/packages/smithy-client/src/ser-utils.ts +++ b/packages/smithy-client/src/ser-utils.ts @@ -25,4 +25,4 @@ export const serializeFloat = (value: number): string | number => { * @param date - to be serialized. * @returns https://smithy.io/2.0/spec/protocol-traits.html#timestampformat-trait date-time format. */ -export const serializeDateTime = (date: Date): string => date.toISOString(); +export const serializeDateTime = (date: Date): string => date.toISOString().replace(".000Z", "Z");