Skip to content

logicalType: date #109

@cfcs

Description

@cfcs

Hi, I have a schema like:

{"name": "birthday",
 "type": "int",
 "logicalType": "date"}

In order to pass a Date sigil into it it has to be converted to "the number of days since unix epoch":

def date2int(d) when is_struct(d, Date) do
  Date.diff(d, ~D[1970-01-01])
end
def date2int(d) when is_binary(d) and 10 == byte_size(d) do
  Date.from_iso8601!(d), ~D[1970-01-01]) # this can obviously fail
end

I don't have the expertise to add handling of logicalType to the library, but leaving it here in case someone else needs this. :-)
ping @stretch

Metadata

Metadata

Assignees

No one assigned

    Labels

    client APIAnything related to the client API and its qualityfeatureSomething new to build

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions