From dcd1640b1be24471d452c6744fe4e29a684f9744 Mon Sep 17 00:00:00 2001 From: Vinicius Brasil Date: Fri, 16 Sep 2022 04:20:32 -0300 Subject: [PATCH] Sort timezone list by current offset (#2229) This commit fixes a bug where the timezone list was sorted by the standard offset, not considering timezone changes. The list was working properly, but sorting was wrong. --- lib/plausible/timezones.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plausible/timezones.ex b/lib/plausible/timezones.ex index cb49320f06..3080880c2b 100644 --- a/lib/plausible/timezones.ex +++ b/lib/plausible/timezones.ex @@ -1,4 +1,5 @@ defmodule Plausible.Timezones do + @spec options() :: [{:key, String.t()}, {:value, String.t()}, {:offset, integer()}] def options do Tzdata.zone_list() |> Enum.map(&build_option/1) @@ -7,7 +8,7 @@ defmodule Plausible.Timezones do defp build_option(timezone_code) do timezone_info = Timex.Timezone.get(timezone_code) - offset_in_minutes = div(timezone_info.offset_utc, -60) + offset_in_minutes = timezone_info |> Timex.Timezone.total_offset() |> div(-60) hhmm_formatted_offset = timezone_info