Skip to content

Commit

Permalink
fix(smithy-client): truncate timestamp at 000 millis (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored May 30, 2024
1 parent 5c88174 commit 3689c94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-hats-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smithy/smithy-client": patch
---

truncate timestamp ending in 000 milliseconds
4 changes: 2 additions & 2 deletions packages/smithy-client/src/ser-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-client/src/ser-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

0 comments on commit 3689c94

Please sign in to comment.