Closed APB9785 closed 3 years ago
It looks related to this: https://github.com/mathieuprog/tz/issues/8
When I create a new project, add tz_extra
, and compile, it works fine for me.
Could you share your environment please?
Sure OS 10.14.6 (Mojave) Elixir 1.12.3 Erlang 24.0.6
It seems a problem concerning Mac machines it seems. But how could that be 😅
defp add_offset_data(time_zones) do
Enum.map(time_zones, fn %{time_zone: time_zone_id} = time_zone ->
{:ok, periods} = Tz.PeriodsProvider.periods(time_zone_id)
{utc_offset, dst_offset, zone_abbr, dst_zone_abbr} =
case hd(periods) do
I'm wondering why would one of the time_zones return an empty list of periods? Is the time_zone_id incorrect/missing?
I would look into the PeriodsProvider module but I can't seem to find it in the Tz repo.
In Tz you have to look into compiler.ex, the module is being compiled in that file.
Also it would be nice to add a failing test (as it works for me I can't make it fail).
I just unit tested this pipeline where the error occurred
IanaFileParser.time_zones_with_country(countries)
|> add_time_zone_links(get_time_zone_links_for_canonical_fun)
|> add_offset_data()
|> Enum.sort_by(
&{&1.country && normalize_string(&1.country.name), &1.utc_offset, &1.time_zone}
)
and everything passed OK. Next I'll try it in a demo project and see if the error is still there.
Error is still there. tz + tz_extra in a new 1.6 project does not compile (same stacktrace as before). Here is the repo: https://github.com/APB9785/tz_error_demo
I think I might encounter the error now, uhmmm.. weird. I'll look into it tomorrow.
The error is cause by the option :reject_time_zone_periods_before_year
. Removing this option will prevent the error.
That will be a quick solution before I fix it.
Note that I don't even know if this option is worth it with the newer version of Tz because I think it might make no difference memory-wise. It needs to be measured (I just don't know how yet). Also this option was more intended for embedded devices that have a very limited amount of memory.
Fixed in 0.20.1
By the way tz_extra
has a dependency on tz
so you don't need tz
in your mix.exs
file
The issue is indeed fixed for me by upgrading to 0.20.1
Adding Tz and Tz_extra (following the Tz readme) gives a compilation error when starting the application: