Hey José,
Thanks for taking the time to check it out!
1. Timezone.convert accounts for this when the timezone changes, but I'm not checking to see if two times within the same timezone are crossing a boundary. That was definitely an oversight, thanks for noticing that!
2. I am actually caching it, but in the process dictionary, but I like the idea of caching it in the app environment even better, I don't know why I didn't think of that.
3. It wouldn't take much to do that. I built the tzfile parser already, so I just need to add the tz database at this point, and write the compilation step.
I do have some questions though, regarding defstruct, that I ran into yesterday. Firstly, after reviewing the source for defstruct in Elixir (in lib/kernel.ex), it looks like there is no t() type being generated for a struct, so specs aren't able to use structs as a type. I've just commented out the specs I have that are checking for struct types, since I'm assuming that's just not complete yet. Secondly, there's some weirdness with pattern matching, and I haven't been able to find a single authoritative source on structs/maps, other than browsing Elixir's source and tests to see how it's being used there, but here's my problem:
So given the following simplified Time module/struct:
defmodule Time do
defstruct hours: 0, mins: 0, secs: 0
def new(hours, mins, secs), do: %Time{hours: hours, mins: mins, secs: secs}
def parse_hours(%Time{:hours => h} = _time), do: h
end
This: Time.new(10, 5, 1) |> Time.parse_hours, gives me this:
** (FunctionClauseError) no function clause matching in Time.parse_hours/1
iex:10: Time.parse_hours(%Time{hours: 10, mins: 5, secs: 1})
Am I doing this wrong? Are there docs around defstruct in the works?
Thanks!
Paul