Skip to content

Commit

Permalink
Rewrite ts to BigDecimal conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Sep 2, 2024
1 parent d2d21f4 commit ad754e3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit ad754e3

Please sign in to comment.