From 3689c9496f6963caca751d14dc13413b31a0689d Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 30 May 2024 12:13:36 -0400 Subject: [PATCH] fix(smithy-client): truncate timestamp at 000 millis (#1295) --- .changeset/lucky-hats-doubt.md | 5 +++++ packages/smithy-client/src/ser-utils.spec.ts | 4 ++-- packages/smithy-client/src/ser-utils.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/lucky-hats-doubt.md 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");