I think there are a few problems with your code but this seems to be main one. I asssume you want to have a patterna match that would catch values of type “naive_datetime” but it won’t work this way. It would match only if datetime
was an atom of :naive_datetime
which obviously does not make sense.
Check out this blog post and some example code by @michalmuskala that will help you to implement easier/proper solution (down in the post). There’s a pattern of delegating to Ecto.Type too shown, so you do not loose all the functionality that you have by default.
What is exactly the thing you’re trying to do here, because it’s not clear. Do you have a custom date/time picker that you have to parse?