From 87535d4b44a9110d40f91c3d699888d07dc1abc9 Mon Sep 17 00:00:00 2001 From: Dario Heinisch Date: Thu, 24 Nov 2022 16:29:50 +0100 Subject: [PATCH 1/2] FEAT: Implement parser for decimal values --- lib/msgpax/packer.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/msgpax/packer.ex b/lib/msgpax/packer.ex index 29dab7f..4f70238 100644 --- a/lib/msgpax/packer.ex +++ b/lib/msgpax/packer.ex @@ -316,3 +316,12 @@ defimpl Msgpax.Packer, for: Any do raise Protocol.UndefinedError, protocol: @protocol, value: term end end + +defimpl Msgpax.Packer, for: Decimal do + def pack(value) do + decimal = Decimal + + decimal.to_string(value) + |> @protocol.BitString.pack() + end +end From 6a06a3f8457a7beb06dcba36f85279800507c443 Mon Sep 17 00:00:00 2001 From: Dario Heinisch Date: Thu, 24 Nov 2022 19:49:07 +0100 Subject: [PATCH 2/2] Add support for Darte --- lib/msgpax/packer.ex | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/msgpax/packer.ex b/lib/msgpax/packer.ex index 4f70238..84f8d5f 100644 --- a/lib/msgpax/packer.ex +++ b/lib/msgpax/packer.ex @@ -325,3 +325,10 @@ defimpl Msgpax.Packer, for: Decimal do |> @protocol.BitString.pack() end end + +defimpl Msgpax.Packer, for: Date do + def pack(value) do + Date.to_iso8601(value) + |> @protocol.BitString.pack() + end +end