From ad754e39b556f8676d0464b0fb229b0498ed4b91 Mon Sep 17 00:00:00 2001 From: ghostbuster91 Date: Mon, 2 Sep 2024 11:33:30 +0200 Subject: [PATCH] Rewrite ts to BigDecimal conversion --- .../smithy4s/internals/DocumentEncoderSchemaVisitor.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/core/src/smithy4s/internals/DocumentEncoderSchemaVisitor.scala b/modules/core/src/smithy4s/internals/DocumentEncoderSchemaVisitor.scala index d7fdd22fb..c6b555d02 100644 --- a/modules/core/src/smithy4s/internals/DocumentEncoderSchemaVisitor.scala +++ b/modules/core/src/smithy4s/internals/DocumentEncoderSchemaVisitor.scala @@ -102,7 +102,11 @@ class DocumentEncoderSchemaVisitor( case DATE_TIME => ts => DString(ts.format(DATE_TIME)) case HTTP_DATE => ts => DString(ts.format(HTTP_DATE)) case EPOCH_SECONDS => - ts => DNumber(BigDecimal(s"${ts.epochSecond}.${ts.nano}")) + ts => + val epochSecondsWithNanos = + BigDecimal(ts.epochSecond) + (BigDecimal(ts.nano) * BigDecimal(10) + .pow(-9)) + DNumber(epochSecondsWithNanos) } case PDocument => from(identity) case PFloat => from(float => DNumber(BigDecimal(float.toDouble)))