michalmuskala / time_format

Fast date/time formatting for elixir
7 stars 3 forks source link

Regression since #9 merged #10

Open ewildgoose opened 3 weeks ago

ewildgoose commented 3 weeks ago

Hi, I really like this module as it's massively faster if you need to format a ton of dates. However, generating custom function formatters is broken since the latest commit, which appeared to be trying to deal with the warning about parenthesis after "bytes()"

With this recent commit, any custom function now fails to match it's parameters and this seems to be because the input is now expecting a map which includes a "bytes" entry?! Something clearly gone awry here

Could the latest commit be reverted please. Ideally with a fix for the deprecation warning in some other way? Thanks

michalmuskala commented 3 weeks ago

Do you have a test-case I could use that shows the error?

ewildgoose commented 3 weeks ago

Hi, apologies, I had assumed it was more trivially reproducible, ok:

A simple module like:

defmodule FormatUtils.DateTimeFormat do
    import TimeFormat.Compiled

    # verbose datetime with year: "Wed 27 Aug 2019 21:21"
    defstrftime :verbose_datetime, "%a %e %b %Y %R"
end

Will fail when called:

DateTimeFormat.verbose_datetime(~U[2000-01-01 00:00:00Z]) 

I don't have the exact error handy, but the shape of it was: "couldn't find a matching function, tried...". Then the functions it shows have a head trying to match a map with one of the fields being bytes.

Elixir 1.17.1 / OTP 26 However, on the server, which was also complaining, I think I have Elixir 1.16.x

I can firm up the error message if needed?