Skip to content

Commit 3689c94

Browse files
authored
fix(smithy-client): truncate timestamp at 000 millis (#1295)
1 parent 5c88174 commit 3689c94

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/lucky-hats-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/smithy-client": patch
3+
---
4+
5+
truncate timestamp ending in 000 milliseconds

packages/smithy-client/src/ser-utils.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ describe("serializeFloat", () => {
1414
});
1515

1616
describe("serializeDateTime", () => {
17-
it("should not truncate at the top of the second", () => {
17+
it("should truncate at the top of the second", () => {
1818
const date = new Date(1716476757761);
1919
date.setMilliseconds(0);
20-
expect(serializeDateTime(date)).toEqual("2024-05-23T15:05:57.000Z");
20+
expect(serializeDateTime(date)).toEqual("2024-05-23T15:05:57Z");
2121
});
2222

2323
it("should not truncate in general", () => {

packages/smithy-client/src/ser-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ export const serializeFloat = (value: number): string | number => {
2525
* @param date - to be serialized.
2626
* @returns https://smithy.io/2.0/spec/protocol-traits.html#timestampformat-trait date-time format.
2727
*/
28-
export const serializeDateTime = (date: Date): string => date.toISOString();
28+
export const serializeDateTime = (date: Date): string => date.toISOString().replace(".000Z", "Z");

0 commit comments

Comments
 (0)